Sync family members with contacts and birthdays
This commit is contained in:
@@ -748,6 +748,26 @@ const MIGRATIONS = [
|
||||
UPDATE calendar_events SET icon = 'drill' WHERE icon = 'tooth';
|
||||
`,
|
||||
},
|
||||
{
|
||||
version: 23,
|
||||
description: 'Link family members with contacts and birthdays',
|
||||
up: `
|
||||
ALTER TABLE contacts ADD COLUMN family_user_id INTEGER REFERENCES users(id) ON DELETE CASCADE;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_contacts_family_user
|
||||
ON contacts(family_user_id) WHERE family_user_id IS NOT NULL;
|
||||
|
||||
ALTER TABLE birthdays ADD COLUMN family_user_id INTEGER REFERENCES users(id) ON DELETE CASCADE;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_birthdays_family_user
|
||||
ON birthdays(family_user_id) WHERE family_user_id IS NOT NULL;
|
||||
|
||||
INSERT INTO contacts (name, category, family_user_id)
|
||||
SELECT display_name, 'Sonstiges', id
|
||||
FROM users
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM contacts WHERE contacts.family_user_id = users.id
|
||||
);
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user