/*
Navicat PGSQL Data Transfer

Source Server         : IWAY-Local
Source Server Version : 90304
Source Host           : localhost:5432
Source Database       : appv4
Source Schema         : public

Target Server Type    : PGSQL
Target Server Version : 90304
File Encoding         : 65001

Date: 2018-06-20 16:00:48
*/


-- ----------------------------
-- Sequence structure for "account_types_id_seq"
-- ----------------------------
DROP SEQUENCE "account_types_id_seq";
CREATE SEQUENCE "account_types_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 5
 CACHE 1;

-- ----------------------------
-- Sequence structure for "brands_id_seq"
-- ----------------------------
DROP SEQUENCE "brands_id_seq";
CREATE SEQUENCE "brands_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 CACHE 1;

-- ----------------------------
-- Sequence structure for "campaigns_id_seq"
-- ----------------------------
DROP SEQUENCE "campaigns_id_seq";
CREATE SEQUENCE "campaigns_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for "campaigns_to_plans_id_seq"
-- ----------------------------
DROP SEQUENCE "campaigns_to_plans_id_seq";
CREATE SEQUENCE "campaigns_to_plans_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for "combinations_id_seq"
-- ----------------------------
DROP SEQUENCE "combinations_id_seq";
CREATE SEQUENCE "combinations_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 5
 CACHE 1;

-- ----------------------------
-- Sequence structure for "devices_id_seq"
-- ----------------------------
DROP SEQUENCE "devices_id_seq";
CREATE SEQUENCE "devices_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 2
 CACHE 1;

-- ----------------------------
-- Sequence structure for "download_limits_id_seq"
-- ----------------------------
DROP SEQUENCE "download_limits_id_seq";
CREATE SEQUENCE "download_limits_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 CACHE 1;

-- ----------------------------
-- Sequence structure for "filter_types_id_seq"
-- ----------------------------
DROP SEQUENCE "filter_types_id_seq";
CREATE SEQUENCE "filter_types_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 CACHE 1;

-- ----------------------------
-- Sequence structure for "filters_id_seq"
-- ----------------------------
DROP SEQUENCE "filters_id_seq";
CREATE SEQUENCE "filters_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 5
 CACHE 1;

-- ----------------------------
-- Sequence structure for "menus_id_seq"
-- ----------------------------
DROP SEQUENCE "menus_id_seq";
CREATE SEQUENCE "menus_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for "models_id_seq"
-- ----------------------------
DROP SEQUENCE "models_id_seq";
CREATE SEQUENCE "models_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 3
 CACHE 1;

-- ----------------------------
-- Sequence structure for "plans_id_seq"
-- ----------------------------
DROP SEQUENCE "plans_id_seq";
CREATE SEQUENCE "plans_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 CACHE 1;

-- ----------------------------
-- Sequence structure for "plans_to_filters_id_seq"
-- ----------------------------
DROP SEQUENCE "plans_to_filters_id_seq";
CREATE SEQUENCE "plans_to_filters_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 10
 CACHE 1;

-- ----------------------------
-- Sequence structure for "profiles_id_seq"
-- ----------------------------
DROP SEQUENCE "profiles_id_seq";
CREATE SEQUENCE "profiles_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for "profiles_to_menus_id_seq"
-- ----------------------------
DROP SEQUENCE "profiles_to_menus_id_seq";
CREATE SEQUENCE "profiles_to_menus_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 32
 CACHE 1;

-- ----------------------------
-- Sequence structure for "recharges_id_seq"
-- ----------------------------
DROP SEQUENCE "recharges_id_seq";
CREATE SEQUENCE "recharges_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 CACHE 1;

-- ----------------------------
-- Sequence structure for "speeds_id_seq"
-- ----------------------------
DROP SEQUENCE "speeds_id_seq";
CREATE SEQUENCE "speeds_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 9
 CACHE 1;

-- ----------------------------
-- Sequence structure for "users_id_seq"
-- ----------------------------
DROP SEQUENCE "users_id_seq";
CREATE SEQUENCE "users_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 8
 CACHE 1;

-- ----------------------------
-- Sequence structure for "users_to_profiles_id_seq"
-- ----------------------------
DROP SEQUENCE "users_to_profiles_id_seq";
CREATE SEQUENCE "users_to_profiles_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 25
 CACHE 1;

-- ----------------------------
-- Table structure for "menus"
-- ----------------------------
DROP TABLE "menus";
CREATE TABLE "menus" (
"id" int4 NOT NULL,
"name" varchar(2044) NOT NULL,
"icon" varchar(2044),
"menus_id" int4,
"alias" varchar(2044) NOT NULL,
"description" text,
"is_leaf" bool NOT NULL,
"orden" int4
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of menus
-- ----------------------------
BEGIN;
INSERT INTO "menus" VALUES ('1', 'Planes', 'fa fa-dashborard', null, 'app_plan', 'Planes', 'f', '2');
INSERT INTO "menus" VALUES ('2', 'Suscriptores', 'fa fa-dashborard', null, 'app_subscriber', 'Suscriptores', 'f', '1');
INSERT INTO "menus" VALUES ('3', 'Filtros', 'fa fa-dash-board', null, 'app_filter', 'Filtros', 'f', '3');
INSERT INTO "menus" VALUES ('4', 'Listar Planes', '', '1', 'app_plan_list', 'Listar Planes', 'f', '1');
INSERT INTO "menus" VALUES ('5', 'Crear Nuevos Planes', '', '1', 'app_plan_add', 'Crear Nuevos Planes', 't', '1');
INSERT INTO "menus" VALUES ('6', 'Editar Planes', '', '1', 'app_plan_update', 'Editar Planes', 't', '1');
INSERT INTO "menus" VALUES ('7', 'Eliminar Planes', '', '1', 'app_plan_delete', 'Eliminar Planes', 't', '1');
INSERT INTO "menus" VALUES ('8', 'Listar Suscriptores', '', '2', 'app_subscriber_list', 'Listar Suscriptores', 't', '1');
INSERT INTO "menus" VALUES ('9', 'Editar Suscriptores', null, '2', 'app_subscriber_update', 'Editar Suscriptores', 't', '1');
COMMIT;

-- ----------------------------
-- Table structure for "profiles"
-- ----------------------------
DROP TABLE "profiles";
CREATE TABLE "profiles" (
"id" int4 DEFAULT nextval('profiles_id_seq'::regclass) NOT NULL,
"name" varchar(2044) NOT NULL,
"description" text
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of profiles
-- ----------------------------
BEGIN;
INSERT INTO "profiles" VALUES ('1', 'ROLE_ADMIN', 'Usuario Administrador en entorno de  desarrollo');
INSERT INTO "profiles" VALUES ('2', 'ROLE_OPERARIO', 'El Operario del Sistema es el usuario que gestionara toda la información referente al almacen de dispositivos.');
INSERT INTO "profiles" VALUES ('3', 'ROLE_VISOR', 'Visualiza la Información del sistema');
INSERT INTO "profiles" VALUES ('4', 'ROLE_API', 'ACCESSO AL API');
COMMIT;

-- ----------------------------
-- Table structure for "profiles_to_menus"
-- ----------------------------
DROP TABLE "profiles_to_menus";
CREATE TABLE "profiles_to_menus" (
"profiles_id" int4 NOT NULL,
"menus_id" int4 NOT NULL,
"id" int4 DEFAULT nextval('profiles_to_menus_id_seq'::regclass) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of profiles_to_menus
-- ----------------------------
BEGIN;
INSERT INTO "profiles_to_menus" VALUES ('3', '3', '9');
INSERT INTO "profiles_to_menus" VALUES ('3', '2', '10');
INSERT INTO "profiles_to_menus" VALUES ('3', '8', '11');
INSERT INTO "profiles_to_menus" VALUES ('3', '1', '12');
INSERT INTO "profiles_to_menus" VALUES ('3', '4', '13');
INSERT INTO "profiles_to_menus" VALUES ('1', '1', '19');
INSERT INTO "profiles_to_menus" VALUES ('1', '4', '20');
INSERT INTO "profiles_to_menus" VALUES ('1', '5', '21');
INSERT INTO "profiles_to_menus" VALUES ('1', '6', '22');
INSERT INTO "profiles_to_menus" VALUES ('1', '7', '23');
INSERT INTO "profiles_to_menus" VALUES ('1', '2', '24');
INSERT INTO "profiles_to_menus" VALUES ('1', '8', '25');
INSERT INTO "profiles_to_menus" VALUES ('1', '9', '26');
INSERT INTO "profiles_to_menus" VALUES ('1', '3', '27');
INSERT INTO "profiles_to_menus" VALUES ('2', '4', '28');
INSERT INTO "profiles_to_menus" VALUES ('2', '2', '29');
INSERT INTO "profiles_to_menus" VALUES ('2', '8', '30');
INSERT INTO "profiles_to_menus" VALUES ('2', '9', '31');
INSERT INTO "profiles_to_menus" VALUES ('2', '3', '32');
COMMIT;

-- ----------------------------
-- Table structure for "users"
-- ----------------------------
DROP TABLE "users";
CREATE TABLE "users" (
"id" int4 DEFAULT nextval('users_id_seq'::regclass) NOT NULL,
"username" varchar(200) NOT NULL,
"password" varchar(200) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO "users" VALUES ('1', 'orange', '$2y$10$yOg0U49r45KDEqceQNW.heE0frKpPOzGslc/klt/8Ad3LnWg.0RYm');
INSERT INTO "users" VALUES ('4', 'usuario', '$2y$13$N1u1ExIJvO.3dAtOV9XBSOGxq0JsL6DEkvjFG8Ck9p/12gxlQ90DC');
INSERT INTO "users" VALUES ('8', 'operador1', '$2y$13$Q8PSevxyvjNYTOGDjPRlp.Tycf/iSlk8yn4JegSsJa9khcfEbMHne');
COMMIT;

-- ----------------------------
-- Table structure for "users_to_profiles"
-- ----------------------------
DROP TABLE "users_to_profiles";
CREATE TABLE "users_to_profiles" (
"users_id" int4 NOT NULL,
"profiles_id" int4 NOT NULL,
"id" int4 DEFAULT nextval('users_to_profiles_id_seq'::regclass) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of users_to_profiles
-- ----------------------------
BEGIN;
INSERT INTO "users_to_profiles" VALUES ('1', '1', '6');
INSERT INTO "users_to_profiles" VALUES ('4', '3', '16');
INSERT INTO "users_to_profiles" VALUES ('8', '2', '22');
INSERT INTO "users_to_profiles" VALUES ('1', '4', '23');
INSERT INTO "users_to_profiles" VALUES ('4', '4', '24');
INSERT INTO "users_to_profiles" VALUES ('8', '4', '25');
COMMIT;

-- ----------------------------
-- Alter Sequences Owned By 
-- ----------------------------
ALTER SEQUENCE "account_types_id_seq" OWNED BY "account_types"."id";
ALTER SEQUENCE "brands_id_seq" OWNED BY "brands"."id";
ALTER SEQUENCE "campaigns_id_seq" OWNED BY "campaigns"."id";
ALTER SEQUENCE "campaigns_to_plans_id_seq" OWNED BY "campaigns_to_plans"."id";
ALTER SEQUENCE "combinations_id_seq" OWNED BY "combinations"."id";
ALTER SEQUENCE "devices_id_seq" OWNED BY "devices"."id";
ALTER SEQUENCE "download_limits_id_seq" OWNED BY "download_limits"."id";
ALTER SEQUENCE "filter_types_id_seq" OWNED BY "filter_types"."id";
ALTER SEQUENCE "filters_id_seq" OWNED BY "filters"."id";
ALTER SEQUENCE "menus_id_seq" OWNED BY "menus"."id";
ALTER SEQUENCE "models_id_seq" OWNED BY "models"."id";
ALTER SEQUENCE "plans_id_seq" OWNED BY "plans"."id";
ALTER SEQUENCE "plans_to_filters_id_seq" OWNED BY "plans_to_filters"."id";
ALTER SEQUENCE "profiles_id_seq" OWNED BY "profiles"."id";
ALTER SEQUENCE "profiles_to_menus_id_seq" OWNED BY "profiles_to_menus"."id";
ALTER SEQUENCE "recharges_id_seq" OWNED BY "recharges"."id";
ALTER SEQUENCE "speeds_id_seq" OWNED BY "speeds"."id";
ALTER SEQUENCE "users_id_seq" OWNED BY "users"."id";
ALTER SEQUENCE "users_to_profiles_id_seq" OWNED BY "users_to_profiles"."id";

-- ----------------------------
-- Primary Key structure for table "menus"
-- ----------------------------
ALTER TABLE "menus" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Primary Key structure for table "profiles"
-- ----------------------------
ALTER TABLE "profiles" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Primary Key structure for table "profiles_to_menus"
-- ----------------------------
ALTER TABLE "profiles_to_menus" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Primary Key structure for table "users"
-- ----------------------------
ALTER TABLE "users" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Primary Key structure for table "users_to_profiles"
-- ----------------------------
ALTER TABLE "users_to_profiles" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Key structure for table "menus"
-- ----------------------------
ALTER TABLE "menus" ADD FOREIGN KEY ("menus_id") REFERENCES "menus" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "profiles_to_menus"
-- ----------------------------
ALTER TABLE "profiles_to_menus" ADD FOREIGN KEY ("menus_id") REFERENCES "menus" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "profiles_to_menus" ADD FOREIGN KEY ("profiles_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "users_to_profiles"
-- ----------------------------
ALTER TABLE "users_to_profiles" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "users_to_profiles" ADD FOREIGN KEY ("profiles_id") REFERENCES "profiles" ("id") ON DELETE RESTRICT ON UPDATE CASCADE;
