feat(customers): add optional group assignees with OR visibility for people, companies, and birthdays
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
-- مسئولان اختیاری روی گروههای مشتری
|
||||
CREATE TABLE IF NOT EXISTS "_CustomerGroupAssignees" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "_CustomerGroupAssignees_AB_unique" ON "_CustomerGroupAssignees"("A", "B");
|
||||
CREATE INDEX IF NOT EXISTS "_CustomerGroupAssignees_B_index" ON "_CustomerGroupAssignees"("B");
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = '_CustomerGroupAssignees_A_fkey'
|
||||
) THEN
|
||||
ALTER TABLE "_CustomerGroupAssignees"
|
||||
ADD CONSTRAINT "_CustomerGroupAssignees_A_fkey"
|
||||
FOREIGN KEY ("A") REFERENCES "CustomerGroup"("id")
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
END IF;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = '_CustomerGroupAssignees_B_fkey'
|
||||
) THEN
|
||||
ALTER TABLE "_CustomerGroupAssignees"
|
||||
ADD CONSTRAINT "_CustomerGroupAssignees_B_fkey"
|
||||
FOREIGN KEY ("B") REFERENCES "User"("id")
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user