From 03c13a6e8ad4ec709a35b7b57f13c6ca19460c2c Mon Sep 17 00:00:00 2001 From: cos Date: Mon, 4 May 2026 20:28:42 +0200 Subject: [PATCH] more hub persistency updates --- packages/postgresql/postgresql.go | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/postgresql/postgresql.go b/packages/postgresql/postgresql.go index d11e156..9b18469 100644 --- a/packages/postgresql/postgresql.go +++ b/packages/postgresql/postgresql.go @@ -81,9 +81,40 @@ func Init(ctx context.Context) { creator UUID NOT NULL REFERENCES users(id), join_role, // TODO set role uuid rgba BIGINT NOT NULL DEFAULT 0 CHECK (rgba BETWEEN 0 AND 4294967295), - user_color_allowed BOOLEAN DEAFAULT FALSE + user_color_allowed BOOLEAN DEAFAULT FALSE, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), ) `) + if err != nil { + panic(err) + } + + _, err = dbConn.Exec(ctx, ` + CREATE TABLE IF NOT EXISTS hub_roles ( + id TINYINT PRIMARY KEY, + parent_id UUID NOT NULL REFERACES hubs(id) ON DELETE CASCADE + name TEXT NOT NULL, + permissions INT NOT NULL DEFAULT 0, + rgba BIGINT NOT NULL DEFAULT 0 CHECK (rgba BETWEEN 0 AND 4294967295), + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + ) + `) + if err != nil { + panic(err) + } + + _, err = dbConn.Exec(ctx, ` + CREATE TABLE IF NOT EXISTS hub_channel ( + id TINYINT PRIMARY KEY, + name TEXT NOT NULL, + permissions INT NOT NULL DEFAULT 0, + rgba BIGINT NOT NULL DEFAULT 0 CHECK (rgba BETWEEN 0 AND 4294967295), + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + ) + `) + if err != nil { + panic(err) + } } func UserSave(ctx context.Context, user *types.User) error {