ipfs-upload/schema/schema.psql

39 lines
1.1 KiB
Plaintext

CREATE TABLE access_token (
uid uuid NOT NULL,
token character varying(512) NOT NULL,
app_name character varying(128),
id uuid DEFAULT gen_random_uuid() NOT NULL
);
CREATE TABLE pins (
id uuid DEFAULT gen_random_uuid() NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
cid character varying(128) NOT NULL,
name character varying(512),
uid uuid NOT NULL,
app_name character varying(128)
);
CREATE TABLE users (
uid uuid DEFAULT gen_random_uuid() NOT NULL,
username character varying(64) NOT NULL
);
ALTER TABLE ONLY access_token
ADD CONSTRAINT access_token_pk PRIMARY KEY (id);
ALTER TABLE ONLY pins
ADD CONSTRAINT pins_pk PRIMARY KEY (id);
ALTER TABLE ONLY users
ADD CONSTRAINT users_pk PRIMARY KEY (uid);
CREATE UNIQUE INDEX access_token_token_uindex ON access_token USING btree (token);
CREATE UNIQUE INDEX pins_cid_uid_uindex ON pins USING btree (cid, uid);
CREATE UNIQUE INDEX users_username_uindex ON users USING btree (username);
ALTER TABLE ONLY access_token
ADD CONSTRAINT access_token_users_uid_fk FOREIGN KEY (uid) REFERENCES users(uid);