snapshot of https://github.com/raimohanska/ourboard.git (master, 2026-09-23; blobs > 131072B omitted)
Some checks failed
build / test (18.x) (push) Failing after 10s
build / lint (18.x) (push) Failing after 0s
build / docker-image (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-23 16:16:17 +05:00
commit d57328655f
233 changed files with 21282 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
exports.up = (pgm) => {
pgm.sql(`
CREATE TABLE IF NOT EXISTS board (id text PRIMARY KEY, name text NOT NULL);
ALTER TABLE board ADD COLUMN IF NOT EXISTS content JSONB NOT NULL;
ALTER TABLE board ADD COLUMN IF NOT EXISTS history JSONB NOT NULL default '[]';
CREATE TABLE IF NOT EXISTS board_event (board_id text REFERENCES board(id), last_serial integer, events JSONB NOT NULL, PRIMARY KEY (board_id, last_serial));
ALTER TABLE board_event ALTER COLUMN last_serial SET NOT NULL;
ALTER TABLE board_event ALTER COLUMN board_id SET NOT NULL;
CREATE TABLE IF NOT EXISTS board_api_token (board_id text REFERENCES board(id), token TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS app_user (id text PRIMARY KEY, email text NOT NULL);
CREATE TABLE IF NOT EXISTS user_board (user_id text REFERENCES app_user(id), board_id text REFERENCES board(id), last_opened TIMESTAMP NOT NULL, PRIMARY KEY (user_id, board_id));
ALTER TABLE board ADD COLUMN IF NOT EXISTS ws_host TEXT NULL;
ALTER TABLE board ADD COLUMN IF NOT EXISTS created_at TIMESTAMP NULL DEFAULT now();
ALTER TABLE board_event ADD COLUMN IF NOT EXISTS saved_at TIMESTAMP NULL DEFAULT now();
`)
}

View File

@@ -0,0 +1,7 @@
exports.up = (pgm) => {
pgm.sql(`
ALTER TABLE board_event ADD COLUMN IF NOT EXISTS first_serial int;
UPDATE board_event SET first_serial = COALESCE(CAST(events#>'{events, 0, serial}' as int), 0);
ALTER TABLE board_event ALTER COLUMN first_serial SET NOT NULL;
`)
}

View File

@@ -0,0 +1,27 @@
alter table board add public_read boolean null;
alter table board add public_write boolean null;
create table board_access (
board_id text not null references board(id),
domain text null,
email text null,
access text null
);
with allow_json as (
select id, jsonb_array_elements(content -> 'accessPolicy' -> 'allowList') as e
from board),
allow_entry as (
select id, e ->> 'domain' as domain, e ->> 'email' as email, e ->> 'access' as access
from allow_json
)
insert into board_access(board_id, domain, email, access) (
select ae.id as board_id, ae.domain, ae.email, ae.access
from allow_entry ae
);
update board
set public_read = coalesce(content -> 'accessPolicy' ->> 'publicRead', 'false') :: boolean,
public_write = coalesce(content -> 'accessPolicy' ->> 'publicWrite', 'false') :: boolean
where content -> 'accessPolicy' is not null

View File

@@ -0,0 +1,4 @@
update board
set public_read = 't',
public_write = 't'
where content -> 'accessPolicy' is null

View File

@@ -0,0 +1 @@
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

View File

@@ -0,0 +1 @@
ALTER TABLE app_user ADD CONSTRAINT unique_email UNIQUE (email);

View File

@@ -0,0 +1 @@
alter table board_event add column crdt_update bytea null;

View File

@@ -0,0 +1,2 @@
alter table board_event alter column first_serial drop not null;
alter table board_event add constraint first_serial_or_crdt check (crdt_update is not null OR first_serial is not null);

View File

@@ -0,0 +1,2 @@
ALTER TABLE board_event DROP CONSTRAINT board_event_pkey;
CREATE INDEX board_event_board_index ON board_event (board_id);

View File

@@ -0,0 +1 @@
alter table board drop column history;