👔 feat: add option to disable banner

This commit is contained in:
2026-03-03 21:25:59 +07:00
parent d858e54fe8
commit a6b2c77bd1
6 changed files with 52 additions and 2 deletions

View File

@ -513,7 +513,7 @@ Table hero_banner {
Table system_preferences {
id String [pk]
key String [not null]
key String [unique, not null]
value String [not null]
description String [not null]
deletedAt DateTime

View File

@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[key]` on the table `system_preferences` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "system_preferences_key_key" ON "system_preferences"("key");

View File

@ -575,7 +575,7 @@ model HeroBanner {
model SystemPreference {
id String @id @db.Uuid
key String @db.VarChar(225)
key String @db.VarChar(225) @unique
value String @db.VarChar(225)
description String @db.Text
deletedAt DateTime?

View File

@ -1,4 +1,5 @@
import { prisma } from "../../src/utils/databases/prisma/connection";
import { systemPreferenceSeed } from "./systemPreference.seed";
import { userRoleSeed } from "./userRole.seed";
import { userSystemSeed } from "./userSystem.seed";
@ -8,6 +9,7 @@ async function main() {
const userSystemSeedResult = await userSystemSeed();
await userRoleSeed(userSystemSeedResult.id);
await systemPreferenceSeed();
console.log("🌳 All seeds completed");
}

View File

@ -0,0 +1,35 @@
import { Prisma } from "@prisma/client";
import { generateUUIDv7 } from "../../src/helpers/databases/uuidv7";
import { prisma } from "../../src/utils/databases/prisma/connection";
export const systemPreferenceSeed = async () => {
const preferences: Prisma.SystemPreferenceUpsertArgs["create"][] = [
{
id: generateUUIDv7(),
key: "REGISTRATION_ENABLED",
value: process.env.ENABLE_REGISTRATION === "true" ? "true" : "false",
description: "Enable or disable user registration",
},
{
id: generateUUIDv7(),
key: "HERO_BANNER_ENABLED",
value: process.env.ENABLE_HERO_BANNER === "true" ? "true" : "false",
description: "Enable or disable hero banner feature",
},
];
await prisma.$transaction(async (tx) => {
return await Promise.all(
preferences.map(
async (pref) =>
await tx.systemPreference.upsert({
where: {
key: pref.key,
},
update: pref,
create: pref,
}),
),
);
});
};