/*
Navicat PGSQL Data Transfer

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

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

Date: 2018-06-09 00:21:14
*/


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

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

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

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

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

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

-- ----------------------------
-- 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 4
 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 4
 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 8
 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"."speeds_id_seq"
-- ----------------------------
-- DROP SEQUENCE "public"."speeds_id_seq";
CREATE SEQUENCE "public"."speeds_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 6
 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 6
 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"."account_types"
-- ----------------------------
-- DROP TABLE "public"."account_types";
CREATE TABLE "public"."account_types" (
"id" int4 DEFAULT nextval('account_types_id_seq'::regclass) NOT NULL,
"name" varchar(200) NOT NULL,
"is_active" char(1) DEFAULT '1'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of account_types
-- ----------------------------
INSERT INTO "public"."account_types" VALUES ('1', 'Pre - Pago', '1');
INSERT INTO "public"."account_types" VALUES ('2', 'Post - Pago', '1');
INSERT INTO "public"."account_types" VALUES ('3', 'Otro', '1');

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

;

-- ----------------------------
-- Records of campaigns
-- ----------------------------

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

;

-- ----------------------------
-- Records of campaigns_to_plans
-- ----------------------------

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

;

-- ----------------------------
-- Records of combinations
-- ----------------------------
INSERT INTO "public"."combinations" VALUES ('1', '1', '1');
INSERT INTO "public"."combinations" VALUES ('2', '2', '2');
INSERT INTO "public"."combinations" VALUES ('3', '3', '3');
INSERT INTO "public"."combinations" VALUES ('4', '4', '4');

-- ----------------------------
-- Table structure for "public"."device_accounts"
-- ----------------------------
-- DROP TABLE "public"."device_accounts";
CREATE TABLE "public"."device_accounts" (
"mac" varchar(100) NOT NULL,
"start_date" int8 NOT NULL,
"end_date" int8 NOT NULL,
"ciu" varchar(50) NOT NULL,
"master_accounts_id" varchar(2044) NOT NULL,
"plans_id" int4 NOT NULL,
"subscribers_id" int4 NOT NULL,
"start_hour" char(5) DEFAULT '00:00'::bpchar NOT NULL,
"end_hour" char(5) DEFAULT '00:00'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of device_accounts
-- ----------------------------
INSERT INTO "public"."device_accounts" VALUES ('123456789090', '1525712400000', '1527526800000', '12', '5412145114', '2', '2', '00:00', '23:00');
INSERT INTO "public"."device_accounts" VALUES ('123456789091', '1525712400000', '1527526800000', '12', '5412145114', '2', '1', '00:00', '23:00');
INSERT INTO "public"."device_accounts" VALUES ('ABCDE1323294', '1527786000000', '1530378000000', '00', '28299517', '4', '5', '00:00', '23:59');
INSERT INTO "public"."device_accounts" VALUES ('ABCDE1323992', '1527786000000', '1528477200000', '00', '20518158741', '3', '4', '00:59', '00:17');

-- ----------------------------
-- Table structure for "public"."download_limits"
-- ----------------------------
-- DROP TABLE "public"."download_limits";
CREATE TABLE "public"."download_limits" (
"id" int4 DEFAULT nextval('download_limits_id_seq'::regclass) NOT NULL,
"code" char(2) NOT NULL,
"value" int4 NOT NULL,
"is_active" char(1) DEFAULT '0'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of download_limits
-- ----------------------------
INSERT INTO "public"."download_limits" VALUES ('1', 'GB', '3', '1');
INSERT INTO "public"."download_limits" VALUES ('2', 'GB', '4', '1');
INSERT INTO "public"."download_limits" VALUES ('3', 'GB', '5', '1');
INSERT INTO "public"."download_limits" VALUES ('4', 'GB', '10', '1');

-- ----------------------------
-- Table structure for "public"."filter_types"
-- ----------------------------
-- DROP TABLE "public"."filter_types";
CREATE TABLE "public"."filter_types" (
"id" int4 DEFAULT nextval('filter_types_id_seq'::regclass) NOT NULL,
"name" varchar(200) NOT NULL,
"is_active" char(1) DEFAULT '1'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of filter_types
-- ----------------------------
INSERT INTO "public"."filter_types" VALUES ('1', 'XXX', '1');
INSERT INTO "public"."filter_types" VALUES ('2', 'RS', '1');
INSERT INTO "public"."filter_types" VALUES ('3', 'GM', '1');
INSERT INTO "public"."filter_types" VALUES ('4', 'VIDEO', '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
-- ----------------------------
INSERT INTO "public"."filters" VALUES ('1', 'Contenido Adulto');
INSERT INTO "public"."filters" VALUES ('2', 'Redes Sociales');
INSERT INTO "public"."filters" VALUES ('3', 'Gaming');
INSERT INTO "public"."filters" VALUES ('4', 'Streaming');

-- ----------------------------
-- Table structure for "public"."master_accounts"
-- ----------------------------
-- DROP TABLE "public"."master_accounts";
CREATE TABLE "public"."master_accounts" (
"ciu" varchar(20) NOT NULL,
"first_name" varchar(2044),
"last_name" varchar(2044),
"phone" varchar(2044),
"email" varchar(2044),
"account_types_id" int4 NOT NULL,
"type_ciu" varchar(10) NOT NULL,
"plans_id" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of master_accounts
-- ----------------------------
INSERT INTO "public"."master_accounts" VALUES ('123456789', 'Teresa', 'Freites', '321543654', 'dsaqwert@hgdf.mop', '2', 'DNI', '2');
INSERT INTO "public"."master_accounts" VALUES ('1234567890', 'Alfredo', 'Blanco', '123456789', 'rvcdas.df_ds@hgsd.com', '1', 'RUC', '4');
INSERT INTO "public"."master_accounts" VALUES ('20518158741', 'YFTEL', 'eIRL', '964604625', 'info@yftelperu.com', '1', 'RUC', '2');
INSERT INTO "public"."master_accounts" VALUES ('28299517', 'Israel', 'Huamani', '999222813', 'ihh@iway.pe', '1', 'DNI', '2');
INSERT INTO "public"."master_accounts" VALUES ('5412145114', 'Carlos', 'Quijada', '123456789', 'zsfasg@dfok.com', '1', 'RUC', '2');
INSERT INTO "public"."master_accounts" VALUES ('987654321', null, null, null, null, '1', 'RUC', '4');

-- ----------------------------
-- 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,
"allow_recharges" char(1) DEFAULT '0'::bpchar NOT NULL,
"speed_up" int4 NOT NULL,
"speed_down" int4 NOT NULL,
"download_limits_id" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of plans
-- ----------------------------
INSERT INTO "public"."plans" VALUES ('2', 'DEMO01', 'demo plan', null, '1527526800000', '1527786000000', '3600', '1', '4', '5', '4');
INSERT INTO "public"."plans" VALUES ('3', 'DEMO01', 'Plan Peru', 'Test de plan', '1525712400000', '1527526800000', '1234121', '1', '1', '1', '1');
INSERT INTO "public"."plans" VALUES ('4', 'FP', 'FiestasPatrias', '1 dia', '1530464400000', '1533056400000', '86400', '1', '3', '2', '4');

-- ----------------------------
-- 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
-- ----------------------------
INSERT INTO "public"."plans_to_filters" VALUES ('2', '4', '3');
INSERT INTO "public"."plans_to_filters" VALUES ('2', '1', '4');
INSERT INTO "public"."plans_to_filters" VALUES ('4', '2', '6');
INSERT INTO "public"."plans_to_filters" VALUES ('4', '1', '8');

-- ----------------------------
-- 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"."speeds"
-- ----------------------------
-- DROP TABLE "public"."speeds";
CREATE TABLE "public"."speeds" (
"id" int4 DEFAULT nextval('speeds_id_seq'::regclass) NOT NULL,
"code" char(4) NOT NULL,
"value" int4 NOT NULL,
"is_active" char(1) DEFAULT '0'::bpchar NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of speeds
-- ----------------------------
INSERT INTO "public"."speeds" VALUES ('1', 'Mbps', '10', '1');
INSERT INTO "public"."speeds" VALUES ('2', 'Mbps', '20', '1');
INSERT INTO "public"."speeds" VALUES ('3', 'Mbps', '30', '1');
INSERT INTO "public"."speeds" VALUES ('4', 'Mbps', '50', '1');
INSERT INTO "public"."speeds" VALUES ('5', 'Mbps', '100', '1');
INSERT INTO "public"."speeds" VALUES ('6', 'Mbps', '1000', '1');

-- ----------------------------
-- Table structure for "public"."subscribers"
-- ----------------------------
-- DROP TABLE "public"."subscribers";
CREATE TABLE "public"."subscribers" (
"id" int4 DEFAULT nextval('subscribers_id_seq'::regclass) NOT NULL,
"ciu" varchar(200) NOT NULL,
"first_name" varchar(200),
"last_name" varchar(200),
"phone" varchar(50),
"email" varchar(100),
"type_ciu" varchar(10) NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of subscribers
-- ----------------------------
INSERT INTO "public"."subscribers" VALUES ('1', '123456789', 'Teresa', 'Freitas', '148254582785', 'redyhdrfsthj.miaef@kps.cop', 'DNI');
INSERT INTO "public"."subscribers" VALUES ('2', '123456789', 'Teresa', 'Freitas', '546231789', 'dsaddasd@dsgfdfg.cpr', 'DNI');
INSERT INTO "public"."subscribers" VALUES ('4', '16742854', 'Felipe', 'Flores', '999438309', 'info2@yftelperu.com', 'DNI');
INSERT INTO "public"."subscribers" VALUES ('5', '404422999', 'Victoria', 'Yupanqui', null, null, 'DNI');
INSERT INTO "public"."subscribers" VALUES ('6', '1354674968746543679643468', null, null, null, null, 'RUC');

-- ----------------------------
-- 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"."account_types_id_seq" OWNED BY "account_types"."id";
ALTER SEQUENCE "public"."campaigns_id_seq" OWNED BY "campaigns"."id";
ALTER SEQUENCE "public"."campaigns_to_plans_id_seq" OWNED BY "campaigns_to_plans"."id";
ALTER SEQUENCE "public"."combinations_id_seq" OWNED BY "combinations"."id";
ALTER SEQUENCE "public"."download_limits_id_seq" OWNED BY "download_limits"."id";
ALTER SEQUENCE "public"."filter_types_id_seq" OWNED BY "filter_types"."id";
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"."speeds_id_seq" OWNED BY "speeds"."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"."account_types"
-- ----------------------------
ALTER TABLE "public"."account_types" ADD PRIMARY KEY ("id");

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

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

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

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

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

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

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

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

-- ----------------------------
-- 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"."speeds"
-- ----------------------------
ALTER TABLE "public"."speeds" 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"."campaigns_to_plans"
-- ----------------------------
ALTER TABLE "public"."campaigns_to_plans" ADD FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."campaigns_to_plans" ADD FOREIGN KEY ("campaigns_id") REFERENCES "public"."campaigns" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

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

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

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

-- ----------------------------
-- 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"
-- ----------------------------
ALTER TABLE "public"."plans" ADD FOREIGN KEY ("speed_down") REFERENCES "public"."speeds" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."plans" ADD FOREIGN KEY ("speed_up") REFERENCES "public"."speeds" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."plans" ADD FOREIGN KEY ("download_limits_id") REFERENCES "public"."download_limits" ("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 ("menus_id") REFERENCES "public"."menus" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."profiles_to_menus" ADD FOREIGN KEY ("profiles_id") REFERENCES "public"."profiles" ("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 ("users_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."users_to_profiles" ADD FOREIGN KEY ("profiles_id") REFERENCES "public"."profiles" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
