reimplemented auth

This commit is contained in:
Niki Wix Skaarup 2025-04-12 02:49:50 +02:00
parent c925697c46
commit 2a6875016e
Signed by: nikiskaarup
GPG key ID: FC2F1B116F6E788C
35 changed files with 906 additions and 233 deletions

View file

@ -0,0 +1,20 @@
CREATE TABLE `user_sessions` (
`token` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`max_age` integer NOT NULL,
`created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
`updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_sessions_token_unique` ON `user_sessions` (`token`);--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`name` text NOT NULL,
`hash` text NOT NULL,
`created_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL,
`updated_at` integer DEFAULT (unixepoch('subsec') * 1000) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);