Rearrange statements in schema.sql
This commit is contained in:
parent
09b06c4fdb
commit
e581f8efae
1 changed files with 24 additions and 24 deletions
|
@ -32,6 +32,30 @@ CREATE TABLE user_account (
|
|||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE oauth_token (
|
||||
id SERIAL PRIMARY KEY,
|
||||
owner_id UUID NOT NULL REFERENCES user_account (id) ON DELETE CASCADE,
|
||||
token VARCHAR(100) UNIQUE NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
expires_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE relationship (
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
relationship_type SMALLINT NOT NULL,
|
||||
UNIQUE (source_id, target_id, relationship_type)
|
||||
);
|
||||
|
||||
CREATE TABLE follow_request (
|
||||
id UUID PRIMARY KEY,
|
||||
source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
request_status SMALLINT NOT NULL,
|
||||
UNIQUE (source_id, target_id)
|
||||
);
|
||||
|
||||
CREATE TABLE post (
|
||||
id UUID PRIMARY KEY,
|
||||
author_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
|
@ -60,22 +84,6 @@ CREATE TABLE post_reaction (
|
|||
UNIQUE (author_id, post_id)
|
||||
);
|
||||
|
||||
CREATE TABLE relationship (
|
||||
id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
relationship_type SMALLINT NOT NULL,
|
||||
UNIQUE (source_id, target_id, relationship_type)
|
||||
);
|
||||
|
||||
CREATE TABLE follow_request (
|
||||
id UUID PRIMARY KEY,
|
||||
source_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
target_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
request_status SMALLINT NOT NULL,
|
||||
UNIQUE (source_id, target_id)
|
||||
);
|
||||
|
||||
CREATE TABLE media_attachment (
|
||||
id UUID PRIMARY KEY,
|
||||
owner_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
|
@ -103,14 +111,6 @@ CREATE TABLE post_tag (
|
|||
PRIMARY KEY (post_id, tag_id)
|
||||
);
|
||||
|
||||
CREATE TABLE oauth_token (
|
||||
id SERIAL PRIMARY KEY,
|
||||
owner_id UUID NOT NULL REFERENCES user_account (id) ON DELETE CASCADE,
|
||||
token VARCHAR(100) UNIQUE NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
expires_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE notification (
|
||||
id SERIAL PRIMARY KEY,
|
||||
sender_id UUID NOT NULL REFERENCES actor_profile (id) ON DELETE CASCADE,
|
||||
|
|
Loading…
Reference in a new issue