This commit is contained in:
2026-08-17 00:40:46 +02:00
parent 93dc70123c
commit 179a47494f
2 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -100,8 +100,9 @@ func main() {
UPDATE companies c UPDATE companies c
SET owner_user_id = u.id, updated_at = now() SET owner_user_id = u.id, updated_at = now()
FROM users u FROM users u
JOIN memberships m ON m.user_id = u.id AND m.company_id = c.id AND m.status = 'active' INNER JOIN memberships m ON m.user_id = u.id AND m.status = 'active'
WHERE c.id = $1 WHERE c.id = m.company_id
AND c.id = $1
AND lower(u.email) = 'a1-primary@descrybe.local'`, companyID) AND lower(u.email) = 'a1-primary@descrybe.local'`, companyID)
if err := tx.Commit(ctx); err != nil { if err := tx.Commit(ctx); err != nil {
+4 -3
View File
@@ -26,10 +26,11 @@ WHERE c.id = sub.company_id
UPDATE companies c UPDATE companies c
SET owner_user_id = u.id SET owner_user_id = u.id
FROM users u FROM users u
JOIN memberships m ON m.user_id = u.id AND m.company_id = c.id AND m.status = 'active' INNER JOIN memberships m ON m.user_id = u.id AND m.status = 'active'
WHERE c.legacy_company_id = '97e1a309-3d23-4aa2-b518-8e8d7afdfec7' WHERE c.id = m.company_id
AND c.legacy_company_id = '97e1a309-3d23-4aa2-b518-8e8d7afdfec7'
AND lower(u.email) = 'a1-primary@descrybe.local'; AND lower(u.email) = 'a1-primary@descrybe.local';
-- +goose Down -- +goose Down
DROP INDEX IF EXISTS companies_owner_user_id_idx; DROP INDEX IF EXISTS companies_owner_user_id_idx;
ALTER TABLE companies DROP COLUMN IF EXISTS owner_user_id; ALTER TABLE companies DROP COLUMN IF EXISTS owner_user_id;