INSERT INTO "public"."menus" ( "id", "name", "icon", "menus_id", "alias", "description", "is_leaf", "orden") 
VALUES ( 74, 'Promociones', 'fa fa-dashborard', null, 'app_promocion', 'Promociones', false, 2 );

INSERT INTO "public"."menus" ( "id", "name", "icon", "menus_id", "alias", "description", "is_leaf", "orden") 
VALUES ( 75, 'Listar promociones', '', 74, 'app_promocion_list', 'Listar promociones', true, 1);
INSERT INTO "public"."menus" ( "id", "name", "icon", "menus_id", "alias", "description", "is_leaf", "orden") 
VALUES ( 76, 'Crear nuevas promociones', '', 74, 'app_promocion_add', 'Crear nuevas promociones', true, 1);
INSERT INTO "public"."menus" ( "id", "name", "icon", "menus_id", "alias", "description", "is_leaf", "orden") 
VALUES ( 77, 'Editar promociones', '', 74, 'app_promocion_update', 'Editar promociones', true, 1);
INSERT INTO "public"."menus" ( "id", "name", "icon", "menus_id", "alias", "description", "is_leaf", "orden") 
VALUES ( 78, 'Eliminar promociones', '', 74, 'app_promocion_delete', 'Eliminar romociones', true, 1);




-- CREATE TABLE "promotions" -----------------------------------
CREATE TABLE "public"."promotions" ( 
	"id" Serial NOT NULL,
	"name" Character Varying( 255 ) NOT NULL,
	"duration" Numeric( 5, 2 ) NOT NULL,
	"duration_type" Character Varying( 50 ) NOT NULL,
	PRIMARY KEY ( "id" ) );
 ;
-- -------------------------------------------------------------

-- CREATE FIELD "seconds" --------------------------------------
ALTER TABLE "public"."promotions" ADD COLUMN "seconds" Bigint NOT NULL;
-- -------------------------------------------------------------

-- CREATE FIELD "is_deleted" -----------------------------------
ALTER TABLE "public"."promotions" ADD COLUMN "is_deleted" Boolean DEFAULT false NOT NULL;
-- -------------------------------------------------------------

-- CREATE FIELD "description" ----------------------------------
ALTER TABLE "public"."promotions" ADD COLUMN "description" Text;
-- -------------------------------------------------------------

-- CREATE TABLE "assigned_promotions" --------------------------
CREATE TABLE "public"."assigned_promotions" ( 
	"id" Serial NOT NULL,
	"recharges_id" UUid NOT NULL,
	"promotions_id" Integer NOT NULL,
	"created_at" Timestamp Without Time Zone NOT NULL,
	PRIMARY KEY ( "id" ) );
 ;
-- -------------------------------------------------------------

-- CREATE FIELD "start_date" -----------------------------------
ALTER TABLE "public"."assigned_promotions" ADD COLUMN "start_date" Timestamp Without Time Zone NOT NULL;
-- -------------------------------------------------------------

-- CREATE FIELD "end_date" -------------------------------------
ALTER TABLE "public"."assigned_promotions" ADD COLUMN "end_date" Timestamp Without Time Zone NOT NULL;
-- -------------------------------------------------------------

-- CREATE INDEX "index_recharges_id" ---------------------------
CREATE INDEX "index_recharges_id" ON "public"."assigned_promotions" USING btree( "recharges_id" );
-- -------------------------------------------------------------

-- CREATE INDEX "index_promotions_assigned_id" -----------------
CREATE INDEX "index_promotions_assigned_id" ON "public"."assigned_promotions" USING btree( "promotions_id" );
-- -------------------------------------------------------------


-- CREATE LINK "public.assigned_promotions.lnk_recharges_assigned_promotions" 
ALTER TABLE "public"."assigned_promotions"
	ADD CONSTRAINT "lnk_recharges_assigned_promotions" FOREIGN KEY ( "recharges_id" )
	REFERENCES "public"."recharges" ( "id" ) MATCH FULL
	ON DELETE Cascade
	ON UPDATE Cascade;
-- -------------------------------------------------------------

-- CREATE LINK "public.assigned_promotions.lnk_promotions_assigned_promotions" 
ALTER TABLE "public"."assigned_promotions"
	ADD CONSTRAINT "lnk_promotions_assigned_promotions" FOREIGN KEY ( "promotions_id" )
	REFERENCES "public"."promotions" ( "id" ) MATCH FULL
	ON DELETE Cascade
	ON UPDATE Cascade;
-- -------------------------------------------------------------

