diff --git a/prisma/migrations/20250121060755_session_table_update/migration.sql b/prisma/migrations/20250121060755_session_table_update/migration.sql new file mode 100644 index 0000000..b1b8f1e --- /dev/null +++ b/prisma/migrations/20250121060755_session_table_update/migration.sql @@ -0,0 +1,20 @@ +/* + Warnings: + + - You are about to drop the column `user_id` on the `session` table. All the data in the column will be lost. + - A unique constraint covering the columns `[sid]` on the table `session` will be added. If there are existing duplicate values, this will fail. + - Made the column `expires_at` on table `session` required. This step will fail if there are existing NULL values in that column. + +*/ +-- DropForeignKey +ALTER TABLE `session` DROP FOREIGN KEY `session_user_id_fkey`; + +-- DropIndex +DROP INDEX `session_user_id_fkey` ON `session`; + +-- AlterTable +ALTER TABLE `session` DROP COLUMN `user_id`, + MODIFY `expires_at` TIMESTAMP(3) NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX `session_sid_key` ON `session`(`sid`); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a137e10..f4deb00 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -22,7 +22,6 @@ model User { updatedAt DateTime? @db.Timestamp(6) @updatedAt @map("updated_at") status Int @db.TinyInt @default(1) - sessions Session[] socialAccounts SocialAccount[] notification Notification? images Image[] @@ -62,12 +61,10 @@ model Notification { model Session { id String @id @db.VarChar(255) - sid String @db.VarChar(255) + sid String @unique @db.VarChar(255) data String @db.VarChar(512) - expiresAt DateTime? @db.Timestamp(3) @map("expires_at") + expiresAt DateTime @db.Timestamp(3) @map("expires_at") - userId BigInt @map("user_id") - user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("session") }