started integrating auth with lucia

This commit is contained in:
Milo Schwartz
2024-10-01 20:48:03 -04:00
parent a33a8d7367
commit fc5dca136f
20 changed files with 1341 additions and 61 deletions

View File

@@ -27,6 +27,13 @@ CREATE TABLE `routes` (
FOREIGN KEY (`exitNodeId`) REFERENCES `exitNodes`(`exitNodeId`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `session` (
`id` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
`expiresAt` integer NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `sites` (
`siteId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`orgId` integer,
@@ -52,11 +59,10 @@ CREATE TABLE `targets` (
FOREIGN KEY (`resourceId`) REFERENCES `resources`(`resourceId`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `users` (
`userId` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`orgId` integer,
`name` text NOT NULL,
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`groups` text,
FOREIGN KEY (`orgId`) REFERENCES `orgs`(`orgId`) ON UPDATE no action ON DELETE cascade
`passwordHash` text NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);

View File

@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "db8ede7f-7ece-463c-be9c-da36b2b20db6",
"id": "fb7ff7a8-20e6-4602-b096-2f2284ad751e",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"exitNodes": {
@@ -173,6 +173,50 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expiresAt": {
"name": "expiresAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"sites": {
"name": "sites",
"columns": {
@@ -345,27 +389,13 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"user": {
"name": "user",
"columns": {
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"orgId": {
"name": "orgId",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"name": {
"name": "name",
"id": {
"name": "id",
"type": "text",
"primaryKey": false,
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
@@ -376,30 +406,24 @@
"notNull": true,
"autoincrement": false
},
"groups": {
"name": "groups",
"passwordHash": {
"name": "passwordHash",
"type": "text",
"primaryKey": false,
"notNull": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"users_orgId_orgs_orgId_fk": {
"name": "users_orgId_orgs_orgId_fk",
"tableFrom": "users",
"tableTo": "orgs",
"columnsFrom": [
"orgId"
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"columnsTo": [
"orgId"
],
"onDelete": "cascade",
"onUpdate": "no action"
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}

View File

@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1727582003591,
"tag": "0000_ancient_blob",
"when": 1727750917675,
"tag": "0000_faithful_katie_power",
"breakpoints": true
}
]