14 lines
743 B
SQL
14 lines
743 B
SQL
CREATE TABLE `account_deletion_requests` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`account_id` text NOT NULL,
|
|
`status` text DEFAULT 'requested' NOT NULL,
|
|
`reason` text,
|
|
`requested_at` text NOT NULL,
|
|
`cancelled_at` text,
|
|
`created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
`updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `idx_account_deletion_one_requested` ON `account_deletion_requests` (`account_id`) WHERE "account_deletion_requests"."status" = 'requested';--> statement-breakpoint
|
|
CREATE INDEX `idx_account_deletion_status_time` ON `account_deletion_requests` (`status`,`requested_at`); |