This commit is contained in:
sam 2023-09-03 00:23:48 +02:00
commit 2586161abd
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
49 changed files with 4171 additions and 0 deletions

View file

@ -0,0 +1,44 @@
-- 2023-04-04: Create initial tables
-- +migrate Up
-- User accounts
-- Many fields in this table are only relevant for local users, but all blogs are associated with an account
-- to make the database schema simpler.
create table accounts (
id text primary key,
username text not null,
domain text, -- if null, is a local account
email text,
password bytea,
unique (username, domain)
);
-- Blogs
-- These are the AP actors.
create table blogs (
id text primary key,
name text not null,
domain text, -- if null, is a local blog
bio text not null,
account_id text not null references accounts (id) on delete cascade,
unique (name, domain)
);
create type post_visibility as enum ('public', 'unlisted', 'followers', 'direct');
create table posts (
id text primary key,
blog_id text not null references blogs (id) on delete cascade,
content text,
source text,
visibility post_visibility not null
);
-- +migrate Down
drop table accounts;
drop table blogs;
drop table posts;

View file

@ -0,0 +1,6 @@
package migrations
import "embed"
//go:embed *.sql
var FS embed.FS