init push
This commit is contained in:
25
migrations/20260529_rename_opcs_to_hems_opcs.sql
Normal file
25
migrations/20260529_rename_opcs_to_hems_opcs.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Rename OPC table to hems_opcs.
|
||||
|
||||
SET @has_opcs := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'opcs'
|
||||
);
|
||||
|
||||
SET @has_hems_opcs := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'hems_opcs'
|
||||
);
|
||||
|
||||
SET @rename_sql := IF(
|
||||
@has_opcs > 0 AND @has_hems_opcs = 0,
|
||||
'RENAME TABLE opcs TO hems_opcs',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @rename_sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user