init push
This commit is contained in:
26
migrations/20260529_rename_hospitals_to_no_icao_codes.sql
Normal file
26
migrations/20260529_rename_hospitals_to_no_icao_codes.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Rename hospital table to no_icao_codes
|
||||
-- This keeps existing data and constraints while moving to the new table name.
|
||||
|
||||
SET @has_hospitals := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'hospitals'
|
||||
);
|
||||
|
||||
SET @has_no_icao_codes := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'no_icao_codes'
|
||||
);
|
||||
|
||||
SET @rename_sql := IF(
|
||||
@has_hospitals > 0 AND @has_no_icao_codes = 0,
|
||||
'RENAME TABLE hospitals TO no_icao_codes',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @rename_sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user