mirror of
https://github.com/SrIzan10/hackymarket.git
synced 2026-06-06 00:56:52 +00:00
feat: authentication!!!!!
This commit is contained in:
40
prisma/migrations/20260331191207_init/migration.sql
Normal file
40
prisma/migrations/20260331191207_init/migration.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"publicKey" TEXT NOT NULL,
|
||||
"slackId" TEXT NOT NULL,
|
||||
"username" TEXT NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Session" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_publicKey_key" ON "User"("publicKey");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_slackId_key" ON "User"("slackId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Session_userId_key" ON "Session"("userId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
29
prisma/migrations/20260331194009_more_tables/migration.sql
Normal file
29
prisma/migrations/20260331194009_more_tables/migration.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[hcaId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `hcaId` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "hcaId" TEXT NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CreateAccount" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"code" TEXT NOT NULL,
|
||||
"publicKey" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "CreateAccount_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CreateAccount_code_key" ON "CreateAccount"("code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CreateAccount_publicKey_key" ON "CreateAccount"("publicKey");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_hcaId_key" ON "User"("hcaId");
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "postgresql"
|
||||
@@ -11,3 +11,35 @@ generator client {
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
hcaId String @unique
|
||||
publicKey String @unique
|
||||
slackId String @unique
|
||||
username String @unique
|
||||
email String @unique
|
||||
|
||||
sessions Session[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// if userid is null, the session is anonymous and will be authenticated.
|
||||
model Session {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int? @unique
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model CreateAccount {
|
||||
id Int @id @default(autoincrement())
|
||||
code String @unique
|
||||
publicKey String @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
Reference in New Issue
Block a user