Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend schema. #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions backend/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- На канале @pgsql в телеграмме гуру postgresql сказали, что можно спокойно использовать text
-- для текстовых данных, а всякие varchar и char по факту являются text плюс различные ограничения.
-- === default db ===
-- articles
create table "articles" (
"uuid" uuid primary key,
"author" text,
"title" text,
"body" text,
"posted" timestamp with time zone not null,
"modified" timestamp with time zone not null,
"published" boolean,
"tags" text,
"alias" text
);

create index "published_idx" on "articles"("published");

-- disposable emails
create table "disposableemails" (
"domain" text primary key,
"state" text,
"json" text
);

-- feedbacks
create table "feedbacks" (
"id" serial primary key,
"email" text,
"message" text,
"ip" inet
);

-- auth tokens
create table "auth_tokens" (
"id" serial primary key,
"jid" text,
"uuid" uuid,
"expires" timestamp with time zone
);

create index "uuid_idx" on "auth_tokens"("uuid");

-- users
create table "users" (
"username" text primary key,
"server" text,
"email" text,
"ip" inet
);

create index "email_idx" on "users"("email");
create index "user_server_id" on "users"("username", "server");


-- === mam db ===
-- mam preferences
create table "archive_prefs" (
"username" text primary key,
"def" text,
"always" text,
"never" text,
"created_at" timestamp with time zone
);

-- mam archive
create table "archive" (
"id" uuid primary key,
"timestamp" timestamp with time zone,
"username" text,
"bare_peer" text,
"kind" text,
"nick" text,
"txt" text,
"xml" text
);

create index "user_peer" on "archive"("username", "bare_peer");