N-FIN-79: migrate database dropping lucia tables

This commit is contained in:
Markus Thielker 2024-04-04 00:49:36 +02:00
parent ba71cbef0e
commit 57f3381829
No known key found for this signature in database
2 changed files with 28 additions and 29 deletions

View file

@ -0,0 +1,28 @@
/*
Warnings:
- You are about to drop the `lucia_session` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `lucia_user` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "categories"
DROP CONSTRAINT "categories_user_id_fkey";
-- DropForeignKey
ALTER TABLE "entities"
DROP CONSTRAINT "entities_user_id_fkey";
-- DropForeignKey
ALTER TABLE "lucia_session"
DROP CONSTRAINT "lucia_session_userId_fkey";
-- DropForeignKey
ALTER TABLE "payments"
DROP CONSTRAINT "payments_user_id_fkey";
-- DropTable
DROP TABLE "lucia_session";
-- DropTable
DROP TABLE "lucia_user";

View file

@ -7,36 +7,9 @@ datasource db {
url = env("DATABASE_URL")
}
model User {
// lucia internal fields
id String @id
sessions Session[]
// custom fields
username String @unique
password String
entities Entity[]
payments Payment[]
categories Category[]
@@map("lucia_user")
}
model Session {
// lucia internal fields
id String @id
userId String
expiresAt DateTime
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
@@map("lucia_session")
}
model Entity {
id Int @id @default(autoincrement())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id])
name String
type EntityType
defaultCategory Category? @relation(fields: [defaultCategoryId], references: [id])
@ -59,7 +32,6 @@ enum EntityType {
model Payment {
id Int @id @default(autoincrement())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id])
amount Int
currency String @default("EUR")
date DateTime @default(now())
@ -79,7 +51,6 @@ model Payment {
model Category {
id Int @id @default(autoincrement())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id])
name String
color String
createdAt DateTime @default(now()) @map("created_at")