From 90298c35907871f8f08498ff1e216ea7869ddcf5 Mon Sep 17 00:00:00 2001 From: Kenshin13 <63159154+Kenshiin13@users.noreply.github.com> Date: Sun, 7 Sep 2025 23:47:32 +0200 Subject: [PATCH] feat: add auto migration --- .../server/migration/v1.13.5/jobType/main.lua | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 [core]/es_extended/server/migration/v1.13.5/jobType/main.lua diff --git a/[core]/es_extended/server/migration/v1.13.5/jobType/main.lua b/[core]/es_extended/server/migration/v1.13.5/jobType/main.lua new file mode 100644 index 00000000..d06f5257 --- /dev/null +++ b/[core]/es_extended/server/migration/v1.13.5/jobType/main.lua @@ -0,0 +1,35 @@ +local esxVersion = "v1.13.5" + +Core.Migrations = Core.Migrations or {} +Core.Migrations[esxVersion] = Core.Migrations[esxVersion] or {} + +if GetResourceKvpInt(("esx_migration:%s"):format(esxVersion)) == 1 then + return +end + +---@return boolean restartRequired +Core.Migrations[esxVersion].jobTypes = function() + print("^4[esx_migration:v1.13.5:jobTypes]^7 Adding job type column to jobs table.") + + local col = MySQL.scalar.await([[ + SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'jobs' + AND COLUMN_NAME = 'type' + ]]) + + if col == 0 then + print("^4[esx_migration:v1.13.5:jobTypes]^7 Column not found, altering jobs table.") + MySQL.update.await([[ + ALTER TABLE `jobs` + ADD COLUMN `type` VARCHAR(50) NOT NULL DEFAULT 'civ' AFTER `label` + ]]) + else + print("^4[esx_migration:v1.13.5:jobTypes]^7 Column already exists, migration not needed.") + return false + end + + print("^4[esx_migration:v1.13.5:jobTypes]^7 Migration complete.") + return true +end