1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-29 23:41:09 +00:00
ibis/migrations/2023-11-28-150402_ibis_setup/up.sql

76 lines
2.2 KiB
MySQL
Raw Normal View History

create table instance (
id serial primary key,
ap_id varchar(255) not null unique,
inbox_url text not null,
articles_url varchar(255) not null unique,
public_key text not null,
private_key text,
last_refreshed_at timestamptz not null default now(),
local bool not null
);
2023-12-08 21:21:31 +00:00
create table person (
id serial primary key,
username text not null,
ap_id varchar(255) not null unique,
inbox_url text not null,
public_key text not null,
private_key text,
last_refreshed_at timestamptz not null default now(),
local bool not null
);
create table local_user (
id serial primary key,
password_encrypted text not null,
person_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL
);
2023-12-05 14:50:10 +00:00
create table instance_follow (
id serial primary key,
2023-12-04 14:10:07 +00:00
instance_id int REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-12-14 16:06:44 +00:00
follower_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-12-04 14:10:07 +00:00
pending boolean not null,
unique(instance_id, follower_id)
);
2023-12-04 14:10:07 +00:00
2023-11-29 15:41:29 +00:00
create table article (
id serial primary key,
title text not null,
text text not null,
2023-12-01 11:11:19 +00:00
ap_id varchar(255) not null unique,
instance_id int REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-11-29 15:41:29 +00:00
local bool not null
);
create table edit (
id serial primary key,
2023-12-18 15:40:27 +00:00
creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-12-05 00:17:02 +00:00
hash uuid not null,
2023-12-01 11:11:19 +00:00
ap_id varchar(255) not null unique,
2023-11-29 15:41:29 +00:00
diff text not null,
2024-01-24 16:12:17 +00:00
summary text not null,
2023-11-29 15:41:29 +00:00
article_id int REFERENCES article ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2024-01-24 16:12:17 +00:00
previous_version_id uuid not null,
created timestamptz not null
2023-12-05 00:17:02 +00:00
);
create table conflict (
id uuid primary key,
diff text not null,
2024-01-24 16:12:17 +00:00
summary text not null,
2023-12-19 14:32:14 +00:00
creator_id int REFERENCES local_user ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-12-05 00:17:02 +00:00
article_id int REFERENCES article ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
previous_version_id uuid not null
2023-12-19 15:15:43 +00:00
);
-- generate a jwt secret
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE jwt_secret (
id serial PRIMARY KEY,
secret varchar NOT NULL DEFAULT gen_random_uuid ()
);
INSERT INTO jwt_secret DEFAULT VALUES;