70 lines
2.3 KiB
SQL
70 lines
2.3 KiB
SQL
CREATE TABLE `account` (
|
|
`id` text PRIMARY KEY,
|
|
`account_id` text NOT NULL,
|
|
`provider_id` text NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`access_token` text,
|
|
`refresh_token` text,
|
|
`id_token` text,
|
|
`access_token_expires_at` integer,
|
|
`refresh_token_expires_at` integer,
|
|
`scope` text,
|
|
`password` text,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
CONSTRAINT `fk_account_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session` (
|
|
`id` text PRIMARY KEY,
|
|
`expires_at` integer NOT NULL,
|
|
`token` text NOT NULL UNIQUE,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
`ip_address` text,
|
|
`user_agent` text,
|
|
`user_id` text NOT NULL,
|
|
`impersonated_by` text,
|
|
CONSTRAINT `fk_session_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `two_factor` (
|
|
`id` text PRIMARY KEY,
|
|
`secret` text NOT NULL,
|
|
`backup_codes` text NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`verified` integer DEFAULT true,
|
|
CONSTRAINT `fk_two_factor_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `user` (
|
|
`id` text PRIMARY KEY,
|
|
`name` text NOT NULL,
|
|
`email` text NOT NULL UNIQUE,
|
|
`email_verified` integer DEFAULT false NOT NULL,
|
|
`image` text,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
`role` text,
|
|
`banned` integer DEFAULT false,
|
|
`ban_reason` text,
|
|
`ban_expires` integer,
|
|
`two_factor_enabled` integer DEFAULT false,
|
|
`username` text UNIQUE,
|
|
`display_username` text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `verification` (
|
|
`id` text PRIMARY KEY,
|
|
`identifier` text NOT NULL,
|
|
`value` text NOT NULL,
|
|
`expires_at` integer NOT NULL,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `account_userId_idx` ON `account` (`user_id`);--> statement-breakpoint
|
|
CREATE INDEX `session_userId_idx` ON `session` (`user_id`);--> statement-breakpoint
|
|
CREATE INDEX `twoFactor_secret_idx` ON `two_factor` (`secret`);--> statement-breakpoint
|
|
CREATE INDEX `twoFactor_userId_idx` ON `two_factor` (`user_id`);--> statement-breakpoint
|
|
CREATE INDEX `verification_identifier_idx` ON `verification` (`identifier`); |