ibis/migrations/2023-11-28-150402_article/up.sql

43 lines
1.3 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
);
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,
follower_id int REFERENCES instance 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-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,
article_id int REFERENCES article ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
2023-12-05 00:17:02 +00:00
previous_version_id uuid not null
);
create table conflict (
id uuid primary key,
diff text not null,
article_id int REFERENCES article ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
previous_version_id uuid not null
);