Try to hack auth

This commit is contained in:
Jared Palmer 2023-06-02 11:15:04 -04:00
parent d88eae7230
commit 030b23985d
19 changed files with 330 additions and 673 deletions

View file

@ -15,23 +15,23 @@ CREATE TABLE IF NOT EXISTS "accounts" (
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_provider_providerAccountId" PRIMARY KEY("provider","providerAccountId");
CREATE TABLE IF NOT EXISTS "sessions" (
"sessionToken" text PRIMARY KEY NOT NULL,
"userId" text NOT NULL,
"expires" timestamp NOT NULL
"sessionToken" text PRIMARY KEY NOT NULL,
"expires" integer NOT NULL
);
CREATE TABLE IF NOT EXISTS "users" (
"id" text PRIMARY KEY NOT NULL,
"name" text,
"email" text NOT NULL,
"emailVerified" timestamp,
"emailVerified" integer,
"image" text
);
CREATE TABLE IF NOT EXISTS "verificationToken" (
"identifier" text NOT NULL,
"token" text NOT NULL,
"expires" timestamp NOT NULL
"expires" integer NOT NULL
);
--> statement-breakpoint
ALTER TABLE "verificationToken" ADD CONSTRAINT "verificationToken_identifier_token" PRIMARY KEY("identifier","token");

View file

@ -1,7 +0,0 @@
ALTER TABLE "accounts" DROP CONSTRAINT "accounts_provider_providerAccountId";
ALTER TABLE "verificationToken" DROP CONSTRAINT "verificationToken_identifier_token";
CREATE UNIQUE INDEX IF NOT EXISTS "Account_provider_providerAccountId_key" ON "accounts" ("provider","providerAccountId");
CREATE UNIQUE INDEX IF NOT EXISTS "Session_sessionToken_key" ON "sessions" ("sessionToken");
CREATE UNIQUE INDEX IF NOT EXISTS "User_email_key" ON "users" ("email");
CREATE UNIQUE INDEX IF NOT EXISTS "VerificationToken_identifier_token_key" ON "verificationToken" ("identifier","token");
CREATE UNIQUE INDEX IF NOT EXISTS "VerificationToken_token_key" ON "verificationToken" ("token");

View file

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS "chats" (
"id" text PRIMARY KEY NOT NULL,
"role" text NOT NULL,
"userId" text NOT NULL
);
DO $$ BEGIN
ALTER TABLE "chats" ADD CONSTRAINT "chats_userId_users_id_fk" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View file

@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "pg",
"id": "ea430ef9-8e30-4cb6-9985-d03f43656cf8",
"id": "c6cb6121-2dc1-49be-8bd9-62f1c0c55939",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"accounts": {
@ -105,21 +105,21 @@
"name": "sessions",
"schema": "",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true
},
"expires": {
"name": "expires",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": true
}
@ -166,7 +166,7 @@
},
"emailVerified": {
"name": "emailVerified",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": false
},
@ -199,7 +199,7 @@
},
"expires": {
"name": "expires",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": true
}

View file

@ -1,8 +1,8 @@
{
"version": "5",
"dialect": "pg",
"id": "34122d24-88e0-430e-862c-2168b0f866cb",
"prevId": "ea430ef9-8e30-4cb6-9985-d03f43656cf8",
"id": "ad52915b-d697-4935-9373-97dca163dd91",
"prevId": "c6cb6121-2dc1-49be-8bd9-62f1c0c55939",
"tables": {
"accounts": {
"name": "accounts",
@ -75,16 +75,7 @@
"notNull": false
}
},
"indexes": {
"Account_provider_providerAccountId_key": {
"name": "Account_provider_providerAccountId_key",
"columns": [
"provider",
"providerAccountId"
],
"isUnique": true
}
},
"indexes": {},
"foreignKeys": {
"accounts_userId_users_id_fk": {
"name": "accounts_userId_users_id_fk",
@ -100,40 +91,81 @@
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {
"accounts_provider_providerAccountId": {
"name": "accounts_provider_providerAccountId",
"columns": [
"provider",
"providerAccountId"
]
}
}
},
"sessions": {
"name": "sessions",
"chats": {
"name": "chats",
"schema": "",
"columns": {
"sessionToken": {
"name": "sessionToken",
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"chats_userId_users_id_fk": {
"name": "chats_userId_users_id_fk",
"tableFrom": "chats",
"tableTo": "users",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {}
},
"sessions": {
"name": "sessions",
"schema": "",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true
},
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true
},
"expires": {
"name": "expires",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"Session_sessionToken_key": {
"name": "Session_sessionToken_key",
"columns": [
"sessionToken"
],
"isUnique": true
}
},
"indexes": {},
"foreignKeys": {
"sessions_userId_users_id_fk": {
"name": "sessions_userId_users_id_fk",
@ -175,7 +207,7 @@
},
"emailVerified": {
"name": "emailVerified",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": false
},
@ -186,15 +218,7 @@
"notNull": false
}
},
"indexes": {
"User_email_key": {
"name": "User_email_key",
"columns": [
"email"
],
"isUnique": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {}
},
@ -216,30 +240,22 @@
},
"expires": {
"name": "expires",
"type": "timestamp",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"VerificationToken_identifier_token_key": {
"name": "VerificationToken_identifier_token_key",
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token": {
"name": "verificationToken_identifier_token",
"columns": [
"identifier",
"token"
],
"isUnique": true
},
"VerificationToken_token_key": {
"name": "VerificationToken_token_key",
"columns": [
"token"
],
"isUnique": true
]
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
}
}
},
"enums": {},

View file

@ -5,15 +5,15 @@
{
"idx": 0,
"version": "5",
"when": 1684771069602,
"tag": "0000_flawless_moondragon",
"when": 1685716228240,
"tag": "0000_clammy_freak",
"breakpoints": false
},
{
"idx": 1,
"version": "5",
"when": 1684771628481,
"tag": "0001_colorful_spectrum",
"when": 1685716937211,
"tag": "0001_petite_sue_storm",
"breakpoints": false
}
]