mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
Merge pull request #1856 from seltonmt012/fix/billing-target-length
fix(es_extended): widen the identifier columns that are too short
This commit is contained in:
+2
-2
@@ -90,7 +90,7 @@ CREATE TABLE `billing` (
|
|||||||
`identifier` varchar(60) NOT NULL,
|
`identifier` varchar(60) NOT NULL,
|
||||||
`sender` varchar(60) NOT NULL,
|
`sender` varchar(60) NOT NULL,
|
||||||
`target_type` varchar(50) NOT NULL,
|
`target_type` varchar(50) NOT NULL,
|
||||||
`target` varchar(40) NOT NULL,
|
`target` varchar(60) NOT NULL,
|
||||||
`label` varchar(255) NOT NULL,
|
`label` varchar(255) NOT NULL,
|
||||||
`amount` int(11) NOT NULL
|
`amount` int(11) NOT NULL
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
@@ -365,7 +365,7 @@ CREATE TABLE `rented_vehicles` (
|
|||||||
`player_name` varchar(255) NOT NULL,
|
`player_name` varchar(255) NOT NULL,
|
||||||
`base_price` int(11) NOT NULL,
|
`base_price` int(11) NOT NULL,
|
||||||
`rent_price` int(11) NOT NULL,
|
`rent_price` int(11) NOT NULL,
|
||||||
`owner` varchar(22) NOT NULL
|
`owner` varchar(60) NOT NULL
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
local esxVersion = "v1.14.2"
|
||||||
|
|
||||||
|
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].billingTargetLength = function()
|
||||||
|
print("^4[esx_migration:v1.14.2:billingTargetLength]^7 Checking the length of billing.target.")
|
||||||
|
|
||||||
|
local length = MySQL.scalar.await([[
|
||||||
|
SELECT CHARACTER_MAXIMUM_LENGTH
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'billing'
|
||||||
|
AND COLUMN_NAME = 'target'
|
||||||
|
]])
|
||||||
|
|
||||||
|
if not length then
|
||||||
|
print("^4[esx_migration:v1.14.2:billingTargetLength]^7 Column not found, migration not needed.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if length >= 60 then
|
||||||
|
print(("^4[esx_migration:v1.14.2:billingTargetLength]^7 Column is already varchar(%s), migration not needed."):format(length))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
print(("^4[esx_migration:v1.14.2:billingTargetLength]^7 Column is varchar(%s), widening it to 60."):format(length))
|
||||||
|
|
||||||
|
MySQL.update.await([[
|
||||||
|
ALTER TABLE `billing`
|
||||||
|
MODIFY `target` VARCHAR(60) NOT NULL
|
||||||
|
]])
|
||||||
|
|
||||||
|
print("^4[esx_migration:v1.14.2:billingTargetLength]^7 Migration complete.")
|
||||||
|
return true
|
||||||
|
end
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
local esxVersion = "v1.14.2"
|
||||||
|
|
||||||
|
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].rentedVehiclesOwnerLength = function()
|
||||||
|
print("^4[esx_migration:v1.14.2:rentedVehiclesOwnerLength]^7 Checking the length of rented_vehicles.owner.")
|
||||||
|
|
||||||
|
local length = MySQL.scalar.await([[
|
||||||
|
SELECT CHARACTER_MAXIMUM_LENGTH
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'rented_vehicles'
|
||||||
|
AND COLUMN_NAME = 'owner'
|
||||||
|
]])
|
||||||
|
|
||||||
|
if not length then
|
||||||
|
print("^4[esx_migration:v1.14.2:rentedVehiclesOwnerLength]^7 Column not found, migration not needed.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if length >= 60 then
|
||||||
|
print(("^4[esx_migration:v1.14.2:rentedVehiclesOwnerLength]^7 Column is already varchar(%s), migration not needed."):format(length))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
print(("^4[esx_migration:v1.14.2:rentedVehiclesOwnerLength]^7 Column is varchar(%s), widening it to 60."):format(length))
|
||||||
|
|
||||||
|
MySQL.update.await([[
|
||||||
|
ALTER TABLE `rented_vehicles`
|
||||||
|
MODIFY `owner` VARCHAR(60) NOT NULL
|
||||||
|
]])
|
||||||
|
|
||||||
|
print("^4[esx_migration:v1.14.2:rentedVehiclesOwnerLength]^7 Migration complete.")
|
||||||
|
return true
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user