From 537f5afa72fd744d89fe02e8c0b56aafa3f7b476 Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Wed, 10 Jul 2024 17:55:27 -0500 Subject: [PATCH] Fix editSetting key value. Signed-off-by: Armored Dragon --- Dockerfile | 4 +--- backend/core/core.js | 5 +++-- wait-for-db.sh | 9 +++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0758527..e368c46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,5 @@ COPY . . EXPOSE 5004 COPY wait-for-db.sh /usr/local/bin/wait-for-db.sh - RUN chmod +x /usr/local/bin/wait-for-db.sh - -CMD ["/usr/local/bin/wait-for-db.sh"] +CMD ["/usr/local/bin/wait-for-db.sh"] \ No newline at end of file diff --git a/backend/core/core.js b/backend/core/core.js index 1de436c..504d53e 100644 --- a/backend/core/core.js +++ b/backend/core/core.js @@ -626,10 +626,11 @@ async function editSetting({ name, value }) { if (!Object.keys(settings).includes(name)) return _r(false, "Setting is not valid"); await prisma.setting.upsert({ where: { id: name }, update: { value: value }, create: { id: name, value: value } }); + try { - settings[key] = JSON.parse(value); + settings[name] = JSON.parse(value); } catch { - settings[key] = value; + settings[name] = value; } return _r(true); diff --git a/wait-for-db.sh b/wait-for-db.sh index 601e316..2568f51 100644 --- a/wait-for-db.sh +++ b/wait-for-db.sh @@ -22,6 +22,12 @@ deploy_migrations() { npx prisma migrate deploy } +# Function to push the Prisma database +push_database() { + echo "Pushing the database..." + npx prisma db push +} + # Wait for the database to be ready wait_for_db @@ -31,6 +37,9 @@ generate_prisma # Deploy Prisma migrations deploy_migrations +# Push the database +push_database + # Start the application echo "Starting the application..." npm start \ No newline at end of file