forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration query + Schedule->EventType to EventType->Schedule (calcom#…
…3140) * Wrote migration query + change Schedule->EventType to EventType->Schedule * Removed warning as it is not strictly true
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...grations/20220622110735_allow_one_schedule_to_apply_to_multiple_event_types/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Schedule" DROP CONSTRAINT "Schedule_eventTypeId_fkey"; | ||
|
||
-- DropIndex | ||
DROP INDEX "Schedule_eventTypeId_key"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "EventType" ADD COLUMN "scheduleId" INTEGER; | ||
|
||
UPDATE "EventType" | ||
SET | ||
"scheduleId" = subquery.id | ||
FROM ( | ||
SELECT id, "eventTypeId" FROM "Schedule" | ||
) AS subquery | ||
WHERE | ||
"EventType".id = subquery."eventTypeId"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Schedule" DROP COLUMN "eventTypeId"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EventType" ADD CONSTRAINT "EventType_scheduleId_fkey" FOREIGN KEY ("scheduleId") REFERENCES "Schedule"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters