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

81 lines
2.3 KiB
MySQL
Raw Normal View History

create table instance (
id serial primary key,
domain text not null unique,
ap_id varchar(255) not null unique,
description text,
articles_url varchar(255) not null unique,
2024-03-11 12:40:03 +00:00
inbox_url varchar(255) not null,
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,
2024-03-11 12:40:03 +00:00
inbox_url varchar(255) not null,
2023-12-08 21:21:31 +00:00
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,
admin bool not null
2023-12-08 21:21:31 +00:00
);
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,
2024-03-05 15:06:27 +00:00
local bool not null,
protected bool not null
2023-11-29 15:41:29 +00:00
);
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 (
2024-02-14 15:09:24 +00:00
id serial primary key,
hash uuid not null,
2023-12-05 00:17:02 +00:00
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;