You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
SQL
43 lines
1.4 KiB
SQL
CREATE TABLE `login_logs` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`session_id` text,
|
|
`user_id` text,
|
|
`browser` text NOT NULL,
|
|
`device` text NOT NULL,
|
|
`os` text NOT NULL,
|
|
`ip` text NOT NULL,
|
|
`logged_in_at` text DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE set null,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `oauth_tokens` (
|
|
`user_id` text NOT NULL,
|
|
`strategy` text NOT NULL,
|
|
`access_token` text NOT NULL,
|
|
`refresh_token` text NOT NULL,
|
|
`created_at` text DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY(`user_id`, `strategy`),
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `sessions` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`userId` text,
|
|
`expires_at` integer NOT NULL,
|
|
FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `users` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`full_name` text,
|
|
`user_name` text,
|
|
`email` text NOT NULL,
|
|
`profile_photo` text,
|
|
`is_blocked` integer DEFAULT false,
|
|
`is_deleted` integer DEFAULT false,
|
|
`created_at` text DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `users_user_name_unique` ON `users` (`user_name`);--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`); |