diff --git a/prisma/migrations/manual-add_app_setting/migration.sql b/prisma/migrations/manual-add_app_setting/migration.sql new file mode 100644 index 0000000..c779520 --- /dev/null +++ b/prisma/migrations/manual-add_app_setting/migration.sql @@ -0,0 +1,18 @@ +-- Manual migration to add AppSetting table +-- This SQL is for SQLite and stores JSON in a TEXT column + +CREATE TABLE IF NOT EXISTS "AppSetting" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT, + "key" TEXT NOT NULL UNIQUE, + "value" TEXT NOT NULL, + "description" TEXT, + "updatedAt" DATETIME NOT NULL DEFAULT (CURRENT_TIMESTAMP), + "updatedBy" TEXT +); + +-- Optional: trigger to update updatedAt on row update +CREATE TRIGGER IF NOT EXISTS "AppSetting_updatedAt" +AFTER UPDATE ON "AppSetting" +BEGIN + UPDATE "AppSetting" SET "updatedAt" = CURRENT_TIMESTAMP WHERE "id" = NEW."id"; +END; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 82c4a60..2ff3859 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -19,3 +19,12 @@ model Stock { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } + +model AppSetting { + id Int @id @default(autoincrement()) + key String @unique + value Json + description String? + updatedAt DateTime @updatedAt + updatedBy String? +}