Add spaces concept (#1776)

This commit is contained in:
Luke Vella 2025-06-15 11:48:51 +02:00 committed by GitHub
parent 92a72dde60
commit 04fcc0350f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 389 additions and 93 deletions

View file

@ -0,0 +1,17 @@
INSERT INTO spaces (id, name, owner_id, created_at, updated_at)
SELECT gen_random_uuid(), 'Personal', id, NOW(), NOW()
FROM users
WHERE NOT EXISTS (
SELECT 1 FROM spaces WHERE spaces.owner_id = users.id
) ON CONFLICT DO NOTHING;
-- Set space_id for polls
UPDATE polls
SET space_id = spaces.id
FROM spaces
WHERE polls.user_id = spaces.owner_id AND polls.space_id IS NULL;
UPDATE subscriptions
SET space_id = spaces.id
FROM spaces
WHERE subscriptions.user_id = spaces.owner_id AND subscriptions.space_id IS NULL;