|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET statement_timeout = 0; |
|
SET lock_timeout = 0; |
|
SET idle_in_transaction_session_timeout = 0; |
|
SET client_encoding = 'UTF8'; |
|
SET standard_conforming_strings = on; |
|
SELECT pg_catalog.set_config('search_path', '', false); |
|
SET check_function_bodies = false; |
|
SET xmloption = content; |
|
SET client_min_messages = warning; |
|
SET row_security = off; |
|
|
|
|
|
|
|
|
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET default_tablespace = ''; |
|
|
|
SET default_table_access_method = heap; |
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE public.files ( |
|
created_at timestamp with time zone DEFAULT now() NOT NULL, |
|
updated_at timestamp with time zone DEFAULT now() NOT NULL, |
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL, |
|
name character varying NOT NULL, |
|
type character varying, |
|
message_id character varying, |
|
mime_type character varying, |
|
size bigint, |
|
uploaded_at timestamp with time zone, |
|
upload_progress double precision, |
|
user_id uuid NOT NULL, |
|
parent_id uuid, |
|
deleted_at timestamp with time zone, |
|
sharing_options character varying[], |
|
signed_key character varying, |
|
file_id character varying, |
|
link_id uuid, |
|
forward_info character varying |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE public.rate_limits ( |
|
key character varying(255) NOT NULL, |
|
points integer DEFAULT 0 NOT NULL, |
|
expire bigint |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE public.usages ( |
|
created_at timestamp with time zone DEFAULT now() NOT NULL, |
|
updated_at timestamp with time zone DEFAULT now() NOT NULL, |
|
key character varying NOT NULL, |
|
usage bigint NOT NULL, |
|
expire timestamp with time zone NOT NULL |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE public.users ( |
|
created_at timestamp with time zone DEFAULT now() NOT NULL, |
|
updated_at timestamp with time zone DEFAULT now() NOT NULL, |
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL, |
|
username character varying NOT NULL, |
|
name character varying, |
|
email character varying, |
|
tg_id character varying, |
|
plan character varying, |
|
subscription_id character varying, |
|
midtrans_id character varying, |
|
plan_expired_at timestamp without time zone, |
|
settings jsonb |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE public.waitings ( |
|
created_at timestamp with time zone DEFAULT now() NOT NULL, |
|
updated_at timestamp with time zone DEFAULT now() NOT NULL, |
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL, |
|
email character varying NOT NULL |
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.files |
|
ADD CONSTRAINT "PK_6c16b9093a142e0e7613b04a3d9" PRIMARY KEY (id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.usages |
|
ADD CONSTRAINT "PK_7d8e95b6dd4c0e87cad4972da13" PRIMARY KEY (key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.users |
|
ADD CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY (id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.waitings |
|
ADD CONSTRAINT "PK_f0cfe98441cf0fb92db66ae71c4" PRIMARY KEY (id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.rate_limits |
|
ADD CONSTRAINT rate_limits_pkey PRIMARY KEY (key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX files_message_id_idx ON public.files USING btree (message_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX files_parent_id_idx ON public.files USING btree (parent_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX files_link_id_idx ON public.files USING btree (link_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX files_user_id_idx ON public.files USING btree (user_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX tg_id ON public.users USING btree (tg_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.files |
|
ADD CONSTRAINT files_files_fkey FOREIGN KEY (parent_id) REFERENCES public.files(id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.files |
|
ADD CONSTRAINT files_links_fkey FOREIGN KEY (link_id) REFERENCES public.files(id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE ONLY public.files |
|
ADD CONSTRAINT files_users_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
|
|
|
|
|
|
|
|
|