/*
 Navicat Premium Data Transfer

 Source Server         : YFTEL-LOCAL
 Source Server Type    : PostgreSQL
 Source Server Version : 100010
 Source Host           : localhost:5432
 Source Catalog        : app2
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 100010
 File Encoding         : 65001

 Date: 30/03/2020 11:52:32
*/


-- ----------------------------
-- Sequence structure for account_types_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."account_types_id_seq";
CREATE SEQUENCE "public"."account_types_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."account_types_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for brands_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."brands_id_seq";
CREATE SEQUENCE "public"."brands_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."brands_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for campaigns_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."campaigns_id_seq";
CREATE SEQUENCE "public"."campaigns_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."campaigns_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for campaigns_to_plans_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."campaigns_to_plans_id_seq";
CREATE SEQUENCE "public"."campaigns_to_plans_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."campaigns_to_plans_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for combinations_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."combinations_id_seq";
CREATE SEQUENCE "public"."combinations_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."combinations_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for download_limits_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."download_limits_id_seq";
CREATE SEQUENCE "public"."download_limits_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."download_limits_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for filter_types_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."filter_types_id_seq";
CREATE SEQUENCE "public"."filter_types_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."filter_types_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for filters_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."filters_id_seq";
CREATE SEQUENCE "public"."filters_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."filters_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for menus_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."menus_id_seq";
CREATE SEQUENCE "public"."menus_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."menus_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for models_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."models_id_seq";
CREATE SEQUENCE "public"."models_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."models_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for plans_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."plans_id_seq";
CREATE SEQUENCE "public"."plans_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."plans_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for plans_to_filters_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."plans_to_filters_id_seq";
CREATE SEQUENCE "public"."plans_to_filters_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."plans_to_filters_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for profiles_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."profiles_id_seq";
CREATE SEQUENCE "public"."profiles_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."profiles_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for profiles_to_menus_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."profiles_to_menus_id_seq";
CREATE SEQUENCE "public"."profiles_to_menus_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."profiles_to_menus_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for speeds_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."speeds_id_seq";
CREATE SEQUENCE "public"."speeds_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."speeds_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Sequence structure for users_to_profiles_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."users_to_profiles_id_seq";
CREATE SEQUENCE "public"."users_to_profiles_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER SEQUENCE "public"."users_to_profiles_id_seq" OWNER TO "postgres";

-- ----------------------------
-- Table structure for account_types
-- ----------------------------
CREATE TABLE "public"."account_types" (
  "id" int8 NOT NULL DEFAULT nextval('account_types_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "is_active" varchar(1) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."account_types" OWNER TO "postgres";

-- ----------------------------
-- Table structure for brands
-- ----------------------------
CREATE TABLE "public"."brands" (
  "id" int8 NOT NULL DEFAULT nextval('brands_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL
)
;
ALTER TABLE "public"."brands" OWNER TO "postgres";

-- ----------------------------
-- Table structure for campaigns
-- ----------------------------
CREATE TABLE "public"."campaigns" (
  "id" int8 NOT NULL DEFAULT nextval('campaigns_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "start_date" int8 NOT NULL,
  "end_date" int8 NOT NULL
)
;
ALTER TABLE "public"."campaigns" OWNER TO "postgres";

-- ----------------------------
-- Table structure for campaigns_to_plans
-- ----------------------------
CREATE TABLE "public"."campaigns_to_plans" (
  "id" int8 NOT NULL DEFAULT nextval('campaigns_to_plans_id_seq'::regclass),
  "campaigns_id" int8 NOT NULL,
  "plans_id" int8 NOT NULL
)
;
ALTER TABLE "public"."campaigns_to_plans" OWNER TO "postgres";

-- ----------------------------
-- Table structure for combinations
-- ----------------------------
CREATE TABLE "public"."combinations" (
  "id" int8 NOT NULL DEFAULT nextval('combinations_id_seq'::regclass),
  "filter_types_id" int8 NOT NULL,
  "filters_id" int8 NOT NULL
)
;
ALTER TABLE "public"."combinations" OWNER TO "postgres";

-- ----------------------------
-- Table structure for devices
-- ----------------------------
CREATE TABLE "public"."devices" (
  "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
  "mac" varchar(12) COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL,
  "pon" text COLLATE "pg_catalog"."default",
  "serie" varchar(200) COLLATE "pg_catalog"."default",
  "mac_wan" varchar(12) COLLATE "pg_catalog"."default",
  "created_at" timestamptz(6),
  "updated_at" timestamptz(6),
  "deleted_at" timestamptz(6),
  "models_id" int8,
  "subscribers_id" varchar(20) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."devices" OWNER TO "postgres";

-- ----------------------------
-- Table structure for download_limits
-- ----------------------------
CREATE TABLE "public"."download_limits" (
  "id" int8 NOT NULL DEFAULT nextval('download_limits_id_seq'::regclass),
  "code" varchar(2) COLLATE "pg_catalog"."default" NOT NULL,
  "value" int8 NOT NULL,
  "is_active" varchar(1) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."download_limits" OWNER TO "postgres";

-- ----------------------------
-- Table structure for filter_types
-- ----------------------------
CREATE TABLE "public"."filter_types" (
  "id" int8 NOT NULL DEFAULT nextval('filter_types_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "is_active" varchar(1) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."filter_types" OWNER TO "postgres";

-- ----------------------------
-- Table structure for filters
-- ----------------------------
CREATE TABLE "public"."filters" (
  "id" int8 NOT NULL DEFAULT nextval('filters_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL
)
;
ALTER TABLE "public"."filters" OWNER TO "postgres";

-- ----------------------------
-- Table structure for menus
-- ----------------------------
CREATE TABLE "public"."menus" (
  "id" int8 NOT NULL DEFAULT nextval('menus_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "icon" text COLLATE "pg_catalog"."default",
  "menus_id" int8,
  "alias" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "description" text COLLATE "pg_catalog"."default",
  "is_leaf" bool,
  "orden" int8
)
;
ALTER TABLE "public"."menus" OWNER TO "postgres";

-- ----------------------------
-- Table structure for models
-- ----------------------------
CREATE TABLE "public"."models" (
  "id" int8 NOT NULL DEFAULT nextval('models_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "equation" text COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL,
  "brands_id" int8 NOT NULL
)
;
ALTER TABLE "public"."models" OWNER TO "postgres";

-- ----------------------------
-- Table structure for plans
-- ----------------------------
CREATE TABLE "public"."plans" (
  "id" int8 NOT NULL DEFAULT nextval('plans_id_seq'::regclass),
  "code" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "description" text COLLATE "pg_catalog"."default",
  "valid_since" int8 NOT NULL,
  "valid_to" int8 NOT NULL,
  "duration" int8 NOT NULL,
  "allow_recharges" varchar(1) COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL,
  "duration_type" varchar(20) COLLATE "pg_catalog"."default",
  "download_limits_id" int8 NOT NULL,
  "speed_down" int8 NOT NULL,
  "speed_up" int8 NOT NULL
)
;
ALTER TABLE "public"."plans" OWNER TO "postgres";

-- ----------------------------
-- Table structure for plans_to_filters
-- ----------------------------
CREATE TABLE "public"."plans_to_filters" (
  "id" int8 NOT NULL DEFAULT nextval('plans_to_filters_id_seq'::regclass),
  "filters_id" int8 NOT NULL,
  "plans_id" int8 NOT NULL
)
;
ALTER TABLE "public"."plans_to_filters" OWNER TO "postgres";

-- ----------------------------
-- Table structure for profiles
-- ----------------------------
CREATE TABLE "public"."profiles" (
  "id" int8 NOT NULL DEFAULT nextval('profiles_id_seq'::regclass),
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "description" text COLLATE "pg_catalog"."default"
)
;
ALTER TABLE "public"."profiles" OWNER TO "postgres";

-- ----------------------------
-- Table structure for profiles_to_menus
-- ----------------------------
CREATE TABLE "public"."profiles_to_menus" (
  "id" int8 NOT NULL DEFAULT nextval('profiles_to_menus_id_seq'::regclass),
  "menus_id" int8 NOT NULL,
  "profiles_id" int8 NOT NULL
)
;
ALTER TABLE "public"."profiles_to_menus" OWNER TO "postgres";

-- ----------------------------
-- Table structure for recharges
-- ----------------------------
CREATE TABLE "public"."recharges" (
  "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
  "is_finished" varchar(1) COLLATE "pg_catalog"."default" NOT NULL,
  "created_at" timestamptz(6),
  "is_deleted" bool NOT NULL,
  "deleted_at" timestamptz(6),
  "start_date" timestamptz(6),
  "end_date" timestamptz(6),
  "devices_id" uuid,
  "plans_id" int8 NOT NULL,
  "subscribers_id" varchar(20) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."recharges" OWNER TO "postgres";

-- ----------------------------
-- Table structure for speeds
-- ----------------------------
CREATE TABLE "public"."speeds" (
  "id" int8 NOT NULL DEFAULT nextval('speeds_id_seq'::regclass),
  "code" varchar(4) COLLATE "pg_catalog"."default" NOT NULL,
  "value" int8 NOT NULL,
  "is_active" varchar(1) COLLATE "pg_catalog"."default" NOT NULL
)
;
ALTER TABLE "public"."speeds" OWNER TO "postgres";

-- ----------------------------
-- Table structure for subscribers
-- ----------------------------
CREATE TABLE "public"."subscribers" (
  "first_name" text COLLATE "pg_catalog"."default",
  "last_name" text COLLATE "pg_catalog"."default",
  "phone" varchar(50) COLLATE "pg_catalog"."default",
  "email" varchar(100) COLLATE "pg_catalog"."default",
  "type_ciu" varchar(10) COLLATE "pg_catalog"."default",
  "ciu" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "is_deleted" bool NOT NULL,
  "account_types_id" int8 NOT NULL
)
;
ALTER TABLE "public"."subscribers" OWNER TO "postgres";

-- ----------------------------
-- Table structure for users
-- ----------------------------
CREATE TABLE "public"."users" (
  "id" uuid NOT NULL DEFAULT uuid_generate_v4(),
  "username" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "password" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "api_key" varchar(200) COLLATE "pg_catalog"."default"
)
;
ALTER TABLE "public"."users" OWNER TO "postgres";

-- ----------------------------
-- Table structure for users_subscribers
-- ----------------------------
CREATE TABLE "public"."users_subscribers" (
  "id" uuid NOT NULL,
  "users_id" uuid,
  "subscribers_id" varchar(20) COLLATE "pg_catalog"."default"
)
;
ALTER TABLE "public"."users_subscribers" OWNER TO "postgres";

-- ----------------------------
-- Table structure for users_to_profiles
-- ----------------------------
CREATE TABLE "public"."users_to_profiles" (
  "id" int8 NOT NULL DEFAULT nextval('users_to_profiles_id_seq'::regclass),
  "profiles_id" int8 NOT NULL,
  "users_id" uuid NOT NULL
)
;
ALTER TABLE "public"."users_to_profiles" OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_generate_v1
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_generate_v1"();
CREATE OR REPLACE FUNCTION "public"."uuid_generate_v1"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_generate_v1'
  LANGUAGE c VOLATILE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_generate_v1"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_generate_v1mc
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_generate_v1mc"();
CREATE OR REPLACE FUNCTION "public"."uuid_generate_v1mc"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_generate_v1mc'
  LANGUAGE c VOLATILE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_generate_v1mc"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_generate_v3
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_generate_v3"("namespace" uuid, "name" text);
CREATE OR REPLACE FUNCTION "public"."uuid_generate_v3"("namespace" uuid, "name" text)
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_generate_v3'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_generate_v3"("namespace" uuid, "name" text) OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_generate_v4
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_generate_v4"();
CREATE OR REPLACE FUNCTION "public"."uuid_generate_v4"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_generate_v4'
  LANGUAGE c VOLATILE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_generate_v4"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_generate_v5
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_generate_v5"("namespace" uuid, "name" text);
CREATE OR REPLACE FUNCTION "public"."uuid_generate_v5"("namespace" uuid, "name" text)
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_generate_v5'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_generate_v5"("namespace" uuid, "name" text) OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_nil
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_nil"();
CREATE OR REPLACE FUNCTION "public"."uuid_nil"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_nil'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_nil"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_ns_dns
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_ns_dns"();
CREATE OR REPLACE FUNCTION "public"."uuid_ns_dns"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_ns_dns'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_ns_dns"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_ns_oid
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_ns_oid"();
CREATE OR REPLACE FUNCTION "public"."uuid_ns_oid"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_ns_oid'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_ns_oid"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_ns_url
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_ns_url"();
CREATE OR REPLACE FUNCTION "public"."uuid_ns_url"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_ns_url'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_ns_url"() OWNER TO "postgres";

-- ----------------------------
-- Function structure for uuid_ns_x500
-- ----------------------------
DROP FUNCTION IF EXISTS "public"."uuid_ns_x500"();
CREATE OR REPLACE FUNCTION "public"."uuid_ns_x500"()
  RETURNS "pg_catalog"."uuid" AS '$libdir/uuid-ossp', 'uuid_ns_x500'
  LANGUAGE c IMMUTABLE STRICT
  COST 1;
ALTER FUNCTION "public"."uuid_ns_x500"() OWNER TO "postgres";

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."account_types_id_seq"
OWNED BY "public"."account_types"."id";
SELECT setval('"public"."account_types_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."brands_id_seq"
OWNED BY "public"."brands"."id";
SELECT setval('"public"."brands_id_seq"', 5, true);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."campaigns_id_seq"
OWNED BY "public"."campaigns"."id";
SELECT setval('"public"."campaigns_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."campaigns_to_plans_id_seq"
OWNED BY "public"."campaigns_to_plans"."id";
SELECT setval('"public"."campaigns_to_plans_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."combinations_id_seq"
OWNED BY "public"."combinations"."id";
SELECT setval('"public"."combinations_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."download_limits_id_seq"
OWNED BY "public"."download_limits"."id";
SELECT setval('"public"."download_limits_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."filter_types_id_seq"
OWNED BY "public"."filter_types"."id";
SELECT setval('"public"."filter_types_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."filters_id_seq"
OWNED BY "public"."filters"."id";
SELECT setval('"public"."filters_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."menus_id_seq"
OWNED BY "public"."menus"."id";
SELECT setval('"public"."menus_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."models_id_seq"
OWNED BY "public"."models"."id";
SELECT setval('"public"."models_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."plans_id_seq"
OWNED BY "public"."plans"."id";
SELECT setval('"public"."plans_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."plans_to_filters_id_seq"
OWNED BY "public"."plans_to_filters"."id";
SELECT setval('"public"."plans_to_filters_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."profiles_id_seq"
OWNED BY "public"."profiles"."id";
SELECT setval('"public"."profiles_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."profiles_to_menus_id_seq"
OWNED BY "public"."profiles_to_menus"."id";
SELECT setval('"public"."profiles_to_menus_id_seq"', 65, true);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."speeds_id_seq"
OWNED BY "public"."speeds"."id";
SELECT setval('"public"."speeds_id_seq"', 2, false);

-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."users_to_profiles_id_seq"
OWNED BY "public"."users_to_profiles"."id";
SELECT setval('"public"."users_to_profiles_id_seq"', 9, true);

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

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

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

-- ----------------------------
-- Indexes structure for table campaigns_to_plans
-- ----------------------------
CREATE INDEX "campaigns_to_plans_campaigns_id_07a3b649" ON "public"."campaigns_to_plans" USING btree (
  "campaigns_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "campaigns_to_plans_plans_id_9c584c29" ON "public"."campaigns_to_plans" USING btree (
  "plans_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table combinations
-- ----------------------------
CREATE INDEX "combinations_filter_types_id_8f35de4f" ON "public"."combinations" USING btree (
  "filter_types_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "combinations_filters_id_789344b1" ON "public"."combinations" USING btree (
  "filters_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table devices
-- ----------------------------
CREATE INDEX "devices_models_id_567aa6d9" ON "public"."devices" USING btree (
  "models_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "devices_subscribers_id_69b8cf0d" ON "public"."devices" USING btree (
  "subscribers_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "devices_subscribers_id_69b8cf0d_like" ON "public"."devices" USING btree (
  "subscribers_id" COLLATE "pg_catalog"."default" "pg_catalog"."varchar_pattern_ops" ASC NULLS LAST
);

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

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

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

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

-- ----------------------------
-- Indexes structure for table menus
-- ----------------------------
CREATE INDEX "menus_menus_id_2c7c8bb7" ON "public"."menus" USING btree (
  "menus_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table models
-- ----------------------------
CREATE INDEX "models_brands_id_f0439c2d" ON "public"."models" USING btree (
  "brands_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table plans
-- ----------------------------
CREATE INDEX "plans_download_limits_id_b884985e" ON "public"."plans" USING btree (
  "download_limits_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "plans_speed_down_6dee07ae" ON "public"."plans" USING btree (
  "speed_down" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "plans_speed_up_74e75268" ON "public"."plans" USING btree (
  "speed_up" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table plans_to_filters
-- ----------------------------
CREATE INDEX "plans_to_filters_filters_id_3c60415b" ON "public"."plans_to_filters" USING btree (
  "filters_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "plans_to_filters_plans_id_777031f7" ON "public"."plans_to_filters" USING btree (
  "plans_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

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

-- ----------------------------
-- Indexes structure for table profiles_to_menus
-- ----------------------------
CREATE INDEX "profiles_to_menus_menus_id_825c6c43" ON "public"."profiles_to_menus" USING btree (
  "menus_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "profiles_to_menus_profiles_id_87357a4e" ON "public"."profiles_to_menus" USING btree (
  "profiles_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Indexes structure for table recharges
-- ----------------------------
CREATE INDEX "recharges_devices_id_f32864d4" ON "public"."recharges" USING btree (
  "devices_id" "pg_catalog"."uuid_ops" ASC NULLS LAST
);
CREATE INDEX "recharges_plans_id_20b3d4f0" ON "public"."recharges" USING btree (
  "plans_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "recharges_subscribers_id_0e3d802e" ON "public"."recharges" USING btree (
  "subscribers_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "recharges_subscribers_id_0e3d802e_like" ON "public"."recharges" USING btree (
  "subscribers_id" COLLATE "pg_catalog"."default" "pg_catalog"."varchar_pattern_ops" ASC NULLS LAST
);

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

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

-- ----------------------------
-- Indexes structure for table subscribers
-- ----------------------------
CREATE INDEX "subscribers_account_types_id_c98b123d" ON "public"."subscribers" USING btree (
  "account_types_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "subscribers_ciu_70813fa2_like" ON "public"."subscribers" USING btree (
  "ciu" COLLATE "pg_catalog"."default" "pg_catalog"."varchar_pattern_ops" ASC NULLS LAST
);

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

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

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

-- ----------------------------
-- Indexes structure for table users_to_profiles
-- ----------------------------
CREATE INDEX "users_to_profiles_profiles_id_0cf3ae29" ON "public"."users_to_profiles" USING btree (
  "profiles_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "users_to_profiles_users_id_bd9001a4" ON "public"."users_to_profiles" USING btree (
  "users_id" "pg_catalog"."uuid_ops" ASC NULLS LAST
);

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

-- ----------------------------
-- Foreign Keys structure for table campaigns_to_plans
-- ----------------------------
ALTER TABLE "public"."campaigns_to_plans" ADD CONSTRAINT "campaigns_to_plans_campaigns_id_07a3b649_fk_campaigns_id" FOREIGN KEY ("campaigns_id") REFERENCES "public"."campaigns" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."campaigns_to_plans" ADD CONSTRAINT "campaigns_to_plans_plans_id_9c584c29_fk_plans_id" FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table combinations
-- ----------------------------
ALTER TABLE "public"."combinations" ADD CONSTRAINT "combinations_filter_types_id_8f35de4f_fk_filter_types_id" FOREIGN KEY ("filter_types_id") REFERENCES "public"."filter_types" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."combinations" ADD CONSTRAINT "combinations_filters_id_789344b1_fk_filters_id" FOREIGN KEY ("filters_id") REFERENCES "public"."filters" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table devices
-- ----------------------------
ALTER TABLE "public"."devices" ADD CONSTRAINT "devices_models_id_567aa6d9_fk_models_id" FOREIGN KEY ("models_id") REFERENCES "public"."models" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."devices" ADD CONSTRAINT "devices_subscribers_id_69b8cf0d_fk_subscribers_ciu" FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("ciu") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table menus
-- ----------------------------
ALTER TABLE "public"."menus" ADD CONSTRAINT "menus_menus_id_2c7c8bb7_fk_menus_id" FOREIGN KEY ("menus_id") REFERENCES "public"."menus" ("id") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table models
-- ----------------------------
ALTER TABLE "public"."models" ADD CONSTRAINT "models_brands_id_f0439c2d_fk_brands_id" FOREIGN KEY ("brands_id") REFERENCES "public"."brands" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table plans
-- ----------------------------
ALTER TABLE "public"."plans" ADD CONSTRAINT "plans_download_limits_id_b884985e_fk_download_limits_id" FOREIGN KEY ("download_limits_id") REFERENCES "public"."download_limits" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."plans" ADD CONSTRAINT "plans_speed_down_6dee07ae_fk_speeds_id" FOREIGN KEY ("speed_down") REFERENCES "public"."speeds" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."plans" ADD CONSTRAINT "plans_speed_up_74e75268_fk_speeds_id" FOREIGN KEY ("speed_up") REFERENCES "public"."speeds" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table plans_to_filters
-- ----------------------------
ALTER TABLE "public"."plans_to_filters" ADD CONSTRAINT "plans_to_filters_filters_id_3c60415b_fk_filters_id" FOREIGN KEY ("filters_id") REFERENCES "public"."filters" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."plans_to_filters" ADD CONSTRAINT "plans_to_filters_plans_id_777031f7_fk_plans_id" FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table profiles_to_menus
-- ----------------------------
ALTER TABLE "public"."profiles_to_menus" ADD CONSTRAINT "profiles_to_menus_menus_id_825c6c43_fk_menus_id" FOREIGN KEY ("menus_id") REFERENCES "public"."menus" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."profiles_to_menus" ADD CONSTRAINT "profiles_to_menus_profiles_id_87357a4e_fk_profiles_id" FOREIGN KEY ("profiles_id") REFERENCES "public"."profiles" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table recharges
-- ----------------------------
ALTER TABLE "public"."recharges" ADD CONSTRAINT "recharges_devices_id_f32864d4_fk_devices_id" FOREIGN KEY ("devices_id") REFERENCES "public"."devices" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."recharges" ADD CONSTRAINT "recharges_plans_id_20b3d4f0_fk_plans_id" FOREIGN KEY ("plans_id") REFERENCES "public"."plans" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."recharges" ADD CONSTRAINT "recharges_subscribers_id_0e3d802e_fk_subscribers_ciu" FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("ciu") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table subscribers
-- ----------------------------
ALTER TABLE "public"."subscribers" ADD CONSTRAINT "subscribers_account_types_id_c98b123d_fk_account_types_id" FOREIGN KEY ("account_types_id") REFERENCES "public"."account_types" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;

-- ----------------------------
-- Foreign Keys structure for table users_subscribers
-- ----------------------------
ALTER TABLE "public"."users_subscribers" ADD CONSTRAINT "users_subscribers_subscribers_id_fkey" FOREIGN KEY ("subscribers_id") REFERENCES "public"."subscribers" ("ciu") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."users_subscribers" ADD CONSTRAINT "users_subscribers_users_id_fkey" FOREIGN KEY ("users_id") REFERENCES "public"."users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Keys structure for table users_to_profiles
-- ----------------------------
ALTER TABLE "public"."users_to_profiles" ADD CONSTRAINT "users_to_profiles_profiles_id_0cf3ae29_fk_profiles_id" FOREIGN KEY ("profiles_id") REFERENCES "public"."profiles" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "public"."users_to_profiles" ADD CONSTRAINT "users_to_profiles_users_id_bd9001a4_fk_users_id" FOREIGN KEY ("users_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
