mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-19 01:07:47 +02:00
✨ Add spaces concept (#1776)
This commit is contained in:
parent
92a72dde60
commit
04fcc0350f
21 changed files with 389 additions and 93 deletions
|
@ -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;
|
Loading…
Add table
Add a link
Reference in a new issue