/*
Navicat PGSQL Data Transfer

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

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

Date: 2018-06-16 05:23: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 5
 CACHE 1;

-- ----------------------------
-- Sequence structure for "public"."brands_id_seq"
-- ----------------------------
-- DROP SEQUENCE "public"."brands_id_seq";
CREATE SEQUENCE "public"."brands_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 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 5
 CACHE 1;

-- ----------------------------
-- Sequence structure for "public"."devices_id_seq"
-- ----------------------------
-- DROP SEQUENCE "public"."devices_id_seq";
CREATE SEQUENCE "public"."devices_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 2
 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 5
 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"."models_id_seq"
-- ----------------------------
-- DROP SEQUENCE "public"."models_id_seq";
CREATE SEQUENCE "public"."models_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 3
 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 10
 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"."recharges_id_seq"
-- ----------------------------
-- DROP SEQUENCE "public"."recharges_id_seq";
CREATE SEQUENCE "public"."recharges_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 4
 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 9
 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');
INSERT INTO "public"."account_types" VALUES ('4', 'Test', '1');
INSERT INTO "public"."account_types" VALUES ('5', '!"·$&/%)(&=?()&?)(&&%$%·%/$', '0');

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

;

-- ----------------------------
-- Records of brands
-- ----------------------------
INSERT INTO "public"."brands" VALUES ('1', 'HUAWEI', 'f');
INSERT INTO "public"."brands" VALUES ('2', 'OPTICTIMES', 'f');
INSERT INTO "public"."brands" VALUES ('3', '!"·$%&/()=?', 't');
INSERT INTO "public"."brands" VALUES ('4', 'ª!"·$%&/()=?¿_:;_', 't');

-- ----------------------------
-- 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');
INSERT INTO "public"."combinations" VALUES ('3', '1', '5');

-- ----------------------------
-- Table structure for "public"."devices"
-- ----------------------------
-- DROP TABLE "public"."devices";
CREATE TABLE "public"."devices" (
"id" int4 DEFAULT nextval('devices_id_seq'::regclass) NOT NULL,
"mac" varchar(12) NOT NULL,
"is_deleted" bool DEFAULT false NOT NULL,
"subscribers_id" varchar(20) NOT NULL,
"pon" varchar(200),
"models_id" int4,
"serie" varchar(200),
"mac_wan" varchar(12)
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of devices
-- ----------------------------
INSERT INTO "public"."devices" VALUES ('1', 'ABC23456CDEE', 'f', '123456789', '839230303', '3', '8383929', 'ABC23456CDF3');
INSERT INTO "public"."devices" VALUES ('2', 'ABC000111110', 'f', '28299517', 'ABC000111110', '2', 'ABC00011111', 'ABC000111111');

-- ----------------------------
-- 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"."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"."models"
-- ----------------------------
-- DROP TABLE "public"."models";
CREATE TABLE "public"."models" (
"id" int4 DEFAULT nextval('models_id_seq'::regclass) NOT NULL,
"name" varchar(2044) NOT NULL,
"equation" varchar(2044) NOT NULL,
"brands_id" int4 NOT NULL,
"is_deleted" bool DEFAULT false NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of models
-- ----------------------------
INSERT INTO "public"."models" VALUES ('1', 'RG2804WT', '8014A8992E84 + 17', '2', 't');
INSERT INTO "public"."models" VALUES ('2', 'HG8245Q2', 'MAC+1', '1', 'f');
INSERT INTO "public"."models" VALUES ('3', 'RG2804WT', 'MAC+5', '2', 'f');

-- ----------------------------
-- 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,
"is_deleted" bool DEFAULT false NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of plans
-- ----------------------------
INSERT INTO "public"."plans" VALUES ('1', 'PLAN01', 'Plan 01', 'Plan descripción', '1527489814574', '1527489818574', '3600', '1', '1', '2', '1', 'f');
INSERT INTO "public"."plans" VALUES ('2', 'Plan2', 'test', 'Pruebas del sistema', '1529341200000', '1529859600000', '3600', '1', '4', '8', '2', 't');
INSERT INTO "public"."plans" VALUES ('3', 'qwe', 'aewrwet', 'aertgae', '1529341200000', '1529859600000', '3600', '1', '1', '1', '1', 't');
INSERT INTO "public"."plans" VALUES ('4', 'P01', 'PROMOCIONJUNIO', 'PROMOCION DE LANZAMIENTO', '1528995600000', '1530378000000', '3600', '1', '9', '9', '1', 'f');

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

-- ----------------------------
-- 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"."recharges"
-- ----------------------------
-- DROP TABLE "public"."recharges";
CREATE TABLE "public"."recharges" (
"id" int4 DEFAULT nextval('recharges_id_seq'::regclass) NOT NULL,
"start_date" int8 NOT NULL,
"start_hour" char(5) DEFAULT '00:00'::bpchar NOT NULL,
"end_date" int8 NOT NULL,
"end_hour" char(5) DEFAULT '00:00'::bpchar NOT NULL,
"is_finished" char(1) DEFAULT '0'::bpchar NOT NULL,
"plans_id" int4 NOT NULL,
"subscribers_id" varchar(20) NOT NULL,
"devices_id" int4
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of recharges
-- ----------------------------
INSERT INTO "public"."recharges" VALUES ('1', '1529038800000', '07:00', '1529038800000', '08:00', '0', '1', '123456789', '1');
INSERT INTO "public"."recharges" VALUES ('2', '1528952400000', '11:00', '1528952400000', '12:00', '0', '1', '123456789', '1');
INSERT INTO "public"."recharges" VALUES ('3', '1528952400000', '15:17', '1528952400000', '16:17', '0', '1', '123456789', '1');
INSERT INTO "public"."recharges" VALUES ('4', '1528952400000', '00:01', '1528952400000', '01:01', '0', '4', '28299517', '2');

-- ----------------------------
-- 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', '0');
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', '0');
INSERT INTO "public"."speeds" VALUES ('7', 'Mbps', '50', '0');
INSERT INTO "public"."speeds" VALUES ('8', 'Mbps', '200', '1');
INSERT INTO "public"."speeds" VALUES ('9', 'Mbps', '300', '1');

-- ----------------------------
-- Table structure for "public"."subscribers"
-- ----------------------------
-- DROP TABLE "public"."subscribers";
CREATE TABLE "public"."subscribers" (
"first_name" varchar(200),
"last_name" varchar(200),
"phone" varchar(50),
"email" varchar(100),
"type_ciu" varchar(10),
"ciu" varchar(20) NOT NULL,
"is_deleted" bool DEFAULT false NOT NULL,
"account_types_id" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of subscribers
-- ----------------------------
INSERT INTO "public"."subscribers" VALUES ('Henderson', 'Farias', '4345235', 'hfarias@da.ed', 'RUC', '12', 't', '3');
INSERT INTO "public"."subscribers" VALUES (null, null, null, null, 'RUC', '123', 't', '4');
INSERT INTO "public"."subscribers" VALUES ('Raul', 'Casti', '14725836', 'rcatillo@pe.pa', 'RUC', '123456789', 'f', '2');
INSERT INTO "public"."subscribers" VALUES ('ISRAEL', 'HUAMANI', '999222813', 'ihh@iway.pe', 'DNI', '28299517', 'f', '1');

-- ----------------------------
-- 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"."brands_id_seq" OWNED BY "brands"."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"."devices_id_seq" OWNED BY "devices"."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"."models_id_seq" OWNED BY "models"."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"."recharges_id_seq" OWNED BY "recharges"."id";
ALTER SEQUENCE "public"."speeds_id_seq" OWNED BY "speeds"."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"."brands"
-- ----------------------------
ALTER TABLE "public"."brands" 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");

-- ----------------------------
-- Indexes structure for table devices
-- ----------------------------
CREATE INDEX "index_models_id" ON "public"."devices" USING btree ("models_id");
CREATE INDEX "index_subscribers_id" ON "public"."devices" USING btree ("subscribers_id");

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

-- ----------------------------
-- 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"."menus"
-- ----------------------------
ALTER TABLE "public"."menus" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table models
-- ----------------------------
CREATE INDEX "index_brands_id" ON "public"."models" USING btree ("brands_id");

-- ----------------------------
-- Primary Key structure for table "public"."models"
-- ----------------------------
ALTER TABLE "public"."models" 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");

-- ----------------------------
-- Indexes structure for table recharges
-- ----------------------------
CREATE INDEX "index_devices_id" ON "public"."recharges" USING btree ("devices_id");
CREATE INDEX "index_subscribers_id1" ON "public"."recharges" USING btree ("subscribers_id");

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

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

-- ----------------------------
-- Indexes structure for table subscribers
-- ----------------------------
CREATE INDEX "index_account_types_id" ON "public"."subscribers" USING btree ("account_types_id");

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

-- ----------------------------
-- 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"."devices"
-- ----------------------------
ALTER TABLE "public"."devices" ADD FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("ciu") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."devices" ADD FOREIGN KEY ("models_id") REFERENCES "public"."models" ("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"."models"
-- ----------------------------
ALTER TABLE "public"."models" ADD FOREIGN KEY ("brands_id") REFERENCES "public"."brands" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."plans"
-- ----------------------------
ALTER TABLE "public"."plans" ADD FOREIGN KEY ("download_limits_id") REFERENCES "public"."download_limits" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
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;

-- ----------------------------
-- Foreign Key structure for table "public"."plans_to_filters"
-- ----------------------------
ALTER TABLE "public"."plans_to_filters" ADD FOREIGN KEY ("filters_id") REFERENCES "public"."filters" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."plans_to_filters" ADD FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("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"."recharges"
-- ----------------------------
ALTER TABLE "public"."recharges" ADD FOREIGN KEY ("devices_id") REFERENCES "public"."devices" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."recharges" ADD FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("ciu") ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE "public"."recharges" ADD FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."subscribers"
-- ----------------------------
ALTER TABLE "public"."subscribers" ADD FOREIGN KEY ("account_types_id") REFERENCES "public"."account_types" ("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;
