/*
Navicat PGSQL Data Transfer

Source Server         : IWAY-Server:5432
Source Server Version : 90223
Source Host           : 10.50.1.28:5432
Source Database       : app
Source Schema         : public

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

Date: 2018-06-09 00:00:57
*/


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

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

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

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

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

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

-- ----------------------------
-- Sequence structure for "public"."subscribers_id_seq"
-- ----------------------------
--DROP SEQUENCE "public"."subscribers_id_seq";
CREATE SEQUENCE "public"."subscribers_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 27
 CACHE 1;

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

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

-- ----------------------------
-- Table structure for "public"."filters"
-- ----------------------------
--DROP TABLE "public"."filters";
CREATE TABLE "public"."filters" (
"id" int4 DEFAULT nextval('filters_id_seq'::regclass) NOT NULL,
"name" varchar(200) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of filters
-- ----------------------------

-- ----------------------------
-- Table structure for "public"."menus"
-- ----------------------------
--DROP TABLE "public"."menus";
CREATE TABLE "public"."menus" (
"id" int4 DEFAULT nextval('menus_id_seq'::regclass) NOT NULL,
"name" varchar(2044) NOT NULL,
"icon" varchar(2044),
"menus_id" int4
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of menus
-- ----------------------------

-- ----------------------------
-- Table structure for "public"."plans"
-- ----------------------------
--DROP TABLE "public"."plans";
CREATE TABLE "public"."plans" (
"id" int4 DEFAULT nextval('plans_id_seq'::regclass) NOT NULL,
"code" varchar(50) NOT NULL,
"name" varchar(200) NOT NULL,
"description" text,
"valid_since" int8 NOT NULL,
"valid_to" int8 NOT NULL,
"duration" int8 NOT NULL,
"speed" int4 NOT NULL,
"speed_code" varchar(10) NOT NULL,
"download" int4 NOT NULL,
"download_code" varchar(2) NOT NULL,
"allow_recharges" char(1) DEFAULT '0'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of plans
-- ----------------------------
INSERT INTO "public"."plans" VALUES ('2', '1', 'Plan_10Mbps', 'Plan 10 Mbps', '1526490000000', '1529600400000', '3600', '10', 'Mbps', '4', 'GB', '1');
INSERT INTO "public"."plans" VALUES ('4', '2', 'Plan_20Mbps', 'Plan 20 Mbps', '1526490000000', '1529600400000', '3600', '20', 'Mbps', '4', 'GB', '1');
INSERT INTO "public"."plans" VALUES ('5', '3', 'Plan_50Mbps', 'Plan 50 Mbps', '1526490000000', '1529600400000', '3600', '50', 'Mbps', '4', 'GB', '1');
INSERT INTO "public"."plans" VALUES ('6', '4', 'Plan_100Mbps', 'Plan 100 Mbps', '1526490000000', '1529600400000', '3600', '100', 'Mbps', '4', 'GB', '1');
INSERT INTO "public"."plans" VALUES ('7', '5', 'Plan_200Mbps', 'Plan 200 Mbps', '1526490000000', '1529600400000', '3600', '200', 'Mbps', '4', 'GB', '1');
INSERT INTO "public"."plans" VALUES ('8', '6', 'Plan_300Mbps', 'Plan 300 Mbps', '1526490000000', '1529600400000', '3600', '300', 'Mbps', '4', 'GB', '1');

-- ----------------------------
-- Table structure for "public"."plans_to_filters"
-- ----------------------------
--DROP TABLE "public"."plans_to_filters";
CREATE TABLE "public"."plans_to_filters" (
"plans_id" int4 NOT NULL,
"filters_id" int4 NOT NULL,
"id" int4 DEFAULT nextval('plans_to_filters_id_seq'::regclass) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of plans_to_filters
-- ----------------------------

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

;

-- ----------------------------
-- Records of profiles
-- ----------------------------

-- ----------------------------
-- Table structure for "public"."profiles_to_menus"
-- ----------------------------
--DROP TABLE "public"."profiles_to_menus";
CREATE TABLE "public"."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
-- ----------------------------

-- ----------------------------
-- Table structure for "public"."subscribers"
-- ----------------------------
--DROP TABLE "public"."subscribers";
CREATE TABLE "public"."subscribers" (
"id" int4 DEFAULT nextval('subscribers_id_seq'::regclass) NOT NULL,
"first_name" varchar(200) NOT NULL,
"last_name" varchar(200) NOT NULL,
"phone" varchar(50),
"email" varchar(100),
"date_since" int8 NOT NULL,
"date_to" int8 NOT NULL,
"mac" varchar(50) NOT NULL,
"account_type" varchar(2044) NOT NULL,
"plans_id" int4 NOT NULL,
"subscribers_id" int4
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of subscribers
-- ----------------------------
INSERT INTO "public"."subscribers" VALUES ('24', 'test', 'prueba', null, null, '1527008400000', '1529686800000', '123456789012', 'PREPAGO', '2', null);
INSERT INTO "public"."subscribers" VALUES ('25', 'romny', 'villegas', null, null, '1527008400000', '1527786000000', '098765432109', 'PREPAGO', '5', null);

-- ----------------------------
-- Table structure for "public"."users"
-- ----------------------------
--DROP TABLE "public"."users";
CREATE TABLE "public"."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
-- ----------------------------
INSERT INTO "public"."users" VALUES ('1', 'orange', '$2y$10$yOg0U49r45KDEqceQNW.heE0frKpPOzGslc/klt/8Ad3LnWg.0RYm');

-- ----------------------------
-- Table structure for "public"."users_to_profiles"
-- ----------------------------
--DROP TABLE "public"."users_to_profiles";
CREATE TABLE "public"."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
-- ----------------------------

-- ----------------------------
-- Alter Sequences Owned By
-- ----------------------------
ALTER SEQUENCE "public"."filters_id_seq" OWNED BY "filters"."id";
ALTER SEQUENCE "public"."menus_id_seq" OWNED BY "menus"."id";
ALTER SEQUENCE "public"."plans_id_seq" OWNED BY "plans"."id";
ALTER SEQUENCE "public"."plans_to_filters_id_seq" OWNED BY "plans_to_filters"."id";
ALTER SEQUENCE "public"."profiles_id_seq" OWNED BY "profiles"."id";
ALTER SEQUENCE "public"."profiles_to_menus_id_seq" OWNED BY "profiles_to_menus"."id";
ALTER SEQUENCE "public"."subscribers_id_seq" OWNED BY "subscribers"."id";
ALTER SEQUENCE "public"."users_id_seq" OWNED BY "users"."id";
ALTER SEQUENCE "public"."users_to_profiles_id_seq" OWNED BY "users_to_profiles"."id";

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

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

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

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

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

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

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

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

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

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

-- ----------------------------
-- Foreign Key structure for table "public"."plans_to_filters"
-- ----------------------------
ALTER TABLE "public"."plans_to_filters" ADD FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."plans_to_filters" ADD FOREIGN KEY ("filters_id") REFERENCES "public"."filters" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

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

-- ----------------------------
-- Foreign Key structure for table "public"."subscribers"
-- ----------------------------
ALTER TABLE "public"."subscribers" ADD FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."subscribers" ADD FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

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