init push
This commit is contained in:
33
migrations/20260626_flight_data_pilot_id_nullable.sql
Normal file
33
migrations/20260626_flight_data_pilot_id_nullable.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- +goose Up
|
||||
SET @has_col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'flight_data'
|
||||
AND column_name = 'pilot_id'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@has_col = 1,
|
||||
'ALTER TABLE flight_data MODIFY COLUMN pilot_id BINARY(16) NULL',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- +goose Down
|
||||
SET @has_col := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'flight_data'
|
||||
AND column_name = 'pilot_id'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@has_col = 1,
|
||||
'ALTER TABLE flight_data MODIFY COLUMN pilot_id BINARY(16) NOT NULL',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user