Initial import: KeepNote service (dcntrlized-auth consumer)

This commit is contained in:
2026-08-14 23:35:38 +01:00
commit 77dfcaf64a
49 changed files with 2346 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
\c dcntrlized;
-- Plain-UUID user_id: drop the legacy FK (D5).
ALTER TABLE IF EXISTS keepnote.notes DROP CONSTRAINT IF EXISTS notes_user_id_fkey;
-- Re-point existing rows to auth.users by username, then drop the old table.
-- No-op on fresh DBs (the old users table never existed).
DO $$
BEGIN
IF EXISTS (SELECT FROM pg_catalog.pg_tables WHERE schemaname='keepnote' AND tablename='users')
AND EXISTS (SELECT FROM pg_catalog.pg_tables WHERE schemaname='auth' AND tablename='users') THEN
UPDATE keepnote.notes n
SET user_id = a.id
FROM keepnote.users old
JOIN auth.users a ON a.username = old.username
WHERE n.user_id = old.id;
DROP TABLE keepnote.users;
END IF;
END $$;