17 lines
1018 B
SQL
17 lines
1018 B
SQL
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
CREATE TABLE `__new_deletion_operations` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`userId` text,
|
|
`guestId` text,
|
|
`undoUntil` integer NOT NULL,
|
|
`createdAt` integer NOT NULL,
|
|
`restoredAt` integer,
|
|
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
|
|
FOREIGN KEY (`guestId`) REFERENCES `guest_sessions`(`id`) ON UPDATE no action ON DELETE no action,
|
|
CONSTRAINT "deletion_subject" CHECK(("__new_deletion_operations"."guestId" IS NOT NULL) + ("__new_deletion_operations"."userId" IS NOT NULL) = 1)
|
|
);
|
|
--> statement-breakpoint
|
|
INSERT INTO `__new_deletion_operations`("id", "userId", "guestId", "undoUntil", "createdAt", "restoredAt") SELECT "id", "userId", "guestId", "undoUntil", "createdAt", "restoredAt" FROM `deletion_operations`;--> statement-breakpoint
|
|
DROP TABLE `deletion_operations`;--> statement-breakpoint
|
|
ALTER TABLE `__new_deletion_operations` RENAME TO `deletion_operations`;--> statement-breakpoint
|
|
PRAGMA foreign_keys=ON; |