init push
This commit is contained in:
26
migrations/20260529_add_name_to_icaos.sql
Normal file
26
migrations/20260529_add_name_to_icaos.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Add optional name field to ICAO table.
|
||||
|
||||
SET @has_table := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'icaos'
|
||||
);
|
||||
|
||||
SET @has_column := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'icaos'
|
||||
AND column_name = 'name'
|
||||
);
|
||||
|
||||
SET @sql := IF(
|
||||
@has_table > 0 AND @has_column = 0,
|
||||
'ALTER TABLE icaos ADD COLUMN name VARCHAR(128) NULL AFTER icao_code',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user