init
This commit is contained in:
commit
2586161abd
49 changed files with 4171 additions and 0 deletions
|
@ -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;
|
6
internal/database/migrations/migrations.go
Normal file
6
internal/database/migrations/migrations.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package migrations
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed *.sql
|
||||
var FS embed.FS
|
Loading…
Add table
Add a link
Reference in a new issue