

ALTER TABLE ONLY public.server_user DROP CONSTRAINT server_user_user_id_fkey;
ALTER TABLE ONLY public.server_user DROP CONSTRAINT server_user_server_id_fkey;
ALTER TABLE ONLY public.port_user DROP CONSTRAINT port_user_user_id_fkey;
ALTER TABLE ONLY public.port_user DROP CONSTRAINT port_user_port_id_fkey;
ALTER TABLE ONLY public.port_usage DROP CONSTRAINT port_usage_port_id_fkey;
ALTER TABLE ONLY public.port DROP CONSTRAINT port_server_id_fkey;
ALTER TABLE ONLY public.port_forward_rule DROP CONSTRAINT port_forward_rule_port_id_fkey;
DROP INDEX public.ix_user_id;
DROP INDEX public.ix_user_email;
DROP INDEX public.ix_server_user_id;
DROP INDEX public.ix_server_name;
DROP INDEX public.ix_server_id;
DROP INDEX public.ix_port_user_id;
DROP INDEX public.ix_port_usage_id;
DROP INDEX public.ix_port_id;
DROP INDEX public.ix_port_forward_rule_id;
ALTER TABLE ONLY public.server_user DROP CONSTRAINT server_user_pkey;
ALTER TABLE ONLY public.port_user DROP CONSTRAINT port_user_pkey;
ALTER TABLE ONLY public.port_usage DROP CONSTRAINT port_usage_pkey;
ALTER TABLE ONLY public.port DROP CONSTRAINT port_pkey;
ALTER TABLE ONLY public.port_forward_rule DROP CONSTRAINT port_forward_rule_pkey;
ALTER TABLE ONLY public.alembic_version DROP CONSTRAINT alembic_version_pkc;
ALTER TABLE ONLY public.server_user DROP CONSTRAINT _server_user_server_id_user_id_uc;
ALTER TABLE ONLY public.port_user DROP CONSTRAINT _port_user_server_id_user_id_uc;
ALTER TABLE ONLY public.port_usage DROP CONSTRAINT _port_usage_port_id_uc;
ALTER TABLE ONLY public.port DROP CONSTRAINT _port_num_server_uc;
ALTER TABLE ONLY public.port DROP CONSTRAINT _port_external_num_server_uc;
ALTER TABLE public.server_user ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.port_user ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.port_usage ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.port_forward_rule ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.port ALTER COLUMN id DROP DEFAULT;
DROP SEQUENCE public.user_id_seq;
DROP SEQUENCE public.server_user_id_seq;
DROP TABLE public.server_user;
DROP SEQUENCE public.server_id_seq;
DROP SEQUENCE public.port_user_id_seq;
DROP TABLE public.port_user;
DROP SEQUENCE public.port_usage_id_seq;
DROP TABLE public.port_usage;
DROP SEQUENCE public.port_id_seq;
DROP SEQUENCE public.port_forward_rule_id_seq;
DROP TABLE public.port_forward_rule;
DROP TABLE public.port;
DROP TABLE public.alembic_version;
DROP TYPE public.methodenum;
--
-- Name: methodenum; Type: TYPE; Schema: public; Owner: aurora
--

CREATE TYPE public.methodenum AS ENUM (
    'IPTABLES',
    'GOST',
    'EHCO',
    'V2RAY',
    'SOCAT',
    'BROOK',
    'WSTUNNEL',
    'NODE_EXPORTER',
    'TINY_PORT_MAPPER',
    'SHADOWSOCKS',
    'CADDY',
    'IPERF',
    'REALM',
    'HAPROXY'
);


ALTER TYPE public.methodenum OWNER TO aurora;



--
-- Name: alembic_version; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.alembic_version (
    version_num character varying(32) NOT NULL
);


ALTER TABLE public.alembic_version OWNER TO aurora;

--
-- Name: port; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.port (
    id integer NOT NULL,
    external_num integer,
    num integer NOT NULL,
    server_id integer,
    config json NOT NULL,
    is_active boolean,
    notes text
);


ALTER TABLE public.port OWNER TO aurora;

--
-- Name: port_forward_rule; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.port_forward_rule (
    id integer NOT NULL,
    port_id integer NOT NULL,
    config json NOT NULL,
    method public.methodenum NOT NULL,
    status character varying,
    is_active boolean
);


ALTER TABLE public.port_forward_rule OWNER TO aurora;

--
-- Name: port_forward_rule_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.port_forward_rule_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.port_forward_rule_id_seq OWNER TO aurora;

--
-- Name: port_forward_rule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.port_forward_rule_id_seq OWNED BY public.port_forward_rule.id;


--
-- Name: port_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.port_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.port_id_seq OWNER TO aurora;

--
-- Name: port_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.port_id_seq OWNED BY public.port.id;


--
-- Name: port_usage; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.port_usage (
    id integer NOT NULL,
    port_id integer NOT NULL,
    download bigint NOT NULL,
    upload bigint NOT NULL,
    download_accumulate bigint NOT NULL,
    upload_accumulate bigint NOT NULL,
    download_checkpoint bigint NOT NULL,
    upload_checkpoint bigint NOT NULL
);


ALTER TABLE public.port_usage OWNER TO aurora;

--
-- Name: port_usage_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.port_usage_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.port_usage_id_seq OWNER TO aurora;

--
-- Name: port_usage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.port_usage_id_seq OWNED BY public.port_usage.id;


--
-- Name: port_user; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.port_user (
    id integer NOT NULL,
    port_id integer NOT NULL,
    user_id integer NOT NULL,
    config json NOT NULL
);


ALTER TABLE public.port_user OWNER TO aurora;

--
-- Name: port_user_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.port_user_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.port_user_id_seq OWNER TO aurora;

--
-- Name: port_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.port_user_id_seq OWNED BY public.port_user.id;

--
-- Name: server_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.server_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.server_id_seq OWNER TO aurora;

--
-- Name: server_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.server_id_seq OWNED BY public.server.id;


--
-- Name: server_user; Type: TABLE; Schema: public; Owner: aurora
--

CREATE TABLE public.server_user (
    id integer NOT NULL,
    server_id integer NOT NULL,
    user_id integer NOT NULL,
    config json NOT NULL,
    download bigint NOT NULL,
    upload bigint NOT NULL,
    notes text
);


ALTER TABLE public.server_user OWNER TO aurora;

--
-- Name: server_user_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.server_user_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.server_user_id_seq OWNER TO aurora;

--
-- Name: server_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.server_user_id_seq OWNED BY public.server_user.id;

--
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: aurora
--

CREATE SEQUENCE public.user_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.user_id_seq OWNER TO aurora;

--
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: aurora
--

ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;


--
-- Name: port id; Type: DEFAULT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port ALTER COLUMN id SET DEFAULT nextval('public.port_id_seq'::regclass);


--
-- Name: port_forward_rule id; Type: DEFAULT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_forward_rule ALTER COLUMN id SET DEFAULT nextval('public.port_forward_rule_id_seq'::regclass);


--
-- Name: port_usage id; Type: DEFAULT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_usage ALTER COLUMN id SET DEFAULT nextval('public.port_usage_id_seq'::regclass);


--
-- Name: port_user id; Type: DEFAULT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_user ALTER COLUMN id SET DEFAULT nextval('public.port_user_id_seq'::regclass);


--
-- Name: server_user id; Type: DEFAULT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.server_user ALTER COLUMN id SET DEFAULT nextval('public.server_user_id_seq'::regclass);


--
-- Data for Name: alembic_version; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.alembic_version (version_num) FROM stdin;
ea4a5dba09c3
\.


--
-- Data for Name: port; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.port (id, external_num, num, server_id, config, is_active, notes) FROM stdin;
1	\N	60000	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
2	\N	60007	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
3	\N	60001	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
4	\N	60002	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
5	\N	60004	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
6	\N	60003	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
7	\N	60005	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
8	\N	60006	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
9	\N	60014	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
10	\N	60022	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
11	\N	60023	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
12	\N	60024	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
13	\N	60025	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
14	\N	60026	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
15	\N	60027	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
16	\N	60028	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
17	\N	60029	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
18	\N	60020	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
19	\N	60035	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
20	\N	60019	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
21	\N	60031	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
22	\N	60018	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
23	\N	60017	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
24	\N	60032	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
25	\N	60016	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
26	\N	60015	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
27	\N	60033	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
28	\N	60021	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
29	\N	60034	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
30	\N	60013	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
31	\N	60012	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
32	\N	60011	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
33	\N	60010	1	{"egress_limit": null, "ingress_limit": null, "valid_until": null, "due_action": 0, "quota": null, "quota_action": 0}	t	\N
\.


--
-- Data for Name: port_forward_rule; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.port_forward_rule (id, port_id, config, method, status, is_active) FROM stdin;
\.


--
-- Data for Name: port_usage; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.port_usage (id, port_id, download, upload, download_accumulate, upload_accumulate, download_checkpoint, upload_checkpoint) FROM stdin;
\.


--
-- Data for Name: port_user; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.port_user (id, port_id, user_id, config) FROM stdin;
\.


--
-- Data for Name: server_user; Type: TABLE DATA; Schema: public; Owner: aurora
--

COPY public.server_user (id, server_id, user_id, config, download, upload, notes) FROM stdin;
\.



--
-- Name: port _port_external_num_server_uc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port
    ADD CONSTRAINT _port_external_num_server_uc UNIQUE (external_num, server_id);


--
-- Name: port _port_num_server_uc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port
    ADD CONSTRAINT _port_num_server_uc UNIQUE (num, server_id);


--
-- Name: port_usage _port_usage_port_id_uc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_usage
    ADD CONSTRAINT _port_usage_port_id_uc UNIQUE (port_id);


--
-- Name: port_user _port_user_server_id_user_id_uc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_user
    ADD CONSTRAINT _port_user_server_id_user_id_uc UNIQUE (port_id, user_id);


--
-- Name: server_user _server_user_server_id_user_id_uc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.server_user
    ADD CONSTRAINT _server_user_server_id_user_id_uc UNIQUE (server_id, user_id);


--
-- Name: alembic_version alembic_version_pkc; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.alembic_version
    ADD CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num);


--
-- Name: port_forward_rule port_forward_rule_pkey; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_forward_rule
    ADD CONSTRAINT port_forward_rule_pkey PRIMARY KEY (id);


--
-- Name: port port_pkey; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port
    ADD CONSTRAINT port_pkey PRIMARY KEY (id);


--
-- Name: port_usage port_usage_pkey; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_usage
    ADD CONSTRAINT port_usage_pkey PRIMARY KEY (id);


--
-- Name: port_user port_user_pkey; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_user
    ADD CONSTRAINT port_user_pkey PRIMARY KEY (id);


--
-- Name: server_user server_user_pkey; Type: CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.server_user
    ADD CONSTRAINT server_user_pkey PRIMARY KEY (id);


--
-- Name: ix_port_forward_rule_id; Type: INDEX; Schema: public; Owner: aurora
--

CREATE INDEX ix_port_forward_rule_id ON public.port_forward_rule USING btree (id);


--
-- Name: ix_port_id; Type: INDEX; Schema: public; Owner: aurora
--

CREATE INDEX ix_port_id ON public.port USING btree (id);


--
-- Name: ix_port_usage_id; Type: INDEX; Schema: public; Owner: aurora
--

CREATE INDEX ix_port_usage_id ON public.port_usage USING btree (id);


--
-- Name: ix_port_user_id; Type: INDEX; Schema: public; Owner: aurora
--

CREATE INDEX ix_port_user_id ON public.port_user USING btree (id);


--
-- Name: ix_server_user_id; Type: INDEX; Schema: public; Owner: aurora
--

CREATE INDEX ix_server_user_id ON public.server_user USING btree (id);


--
-- Name: port_forward_rule port_forward_rule_port_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_forward_rule
    ADD CONSTRAINT port_forward_rule_port_id_fkey FOREIGN KEY (port_id) REFERENCES public.port(id);


--
-- Name: port port_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port
    ADD CONSTRAINT port_server_id_fkey FOREIGN KEY (server_id) REFERENCES public.server(id);


--
-- Name: port_usage port_usage_port_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_usage
    ADD CONSTRAINT port_usage_port_id_fkey FOREIGN KEY (port_id) REFERENCES public.port(id);


--
-- Name: port_user port_user_port_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_user
    ADD CONSTRAINT port_user_port_id_fkey FOREIGN KEY (port_id) REFERENCES public.port(id);


--
-- Name: port_user port_user_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.port_user
    ADD CONSTRAINT port_user_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id);


--
-- Name: server_user server_user_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.server_user
    ADD CONSTRAINT server_user_server_id_fkey FOREIGN KEY (server_id) REFERENCES public.server(id);


--
-- Name: server_user server_user_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: aurora
--

ALTER TABLE ONLY public.server_user
    ADD CONSTRAINT server_user_user_id_fkey FOREIGN KEY (user_id) REFERENCES public."user"(id);