init push
This commit is contained in:
51
migrations/20260424_drop_bases_default_shift_time.sql
Normal file
51
migrations/20260424_drop_bases_default_shift_time.sql
Normal file
@@ -0,0 +1,51 @@
|
||||
-- +goose Up
|
||||
SET @bases_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'bases'
|
||||
);
|
||||
|
||||
SET @col_default_shift_time_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'bases'
|
||||
AND column_name = 'default_shift_time'
|
||||
);
|
||||
|
||||
SET @drop_default_shift_time_sql := IF(
|
||||
@bases_exists > 0 AND @col_default_shift_time_exists > 0,
|
||||
'ALTER TABLE bases DROP COLUMN default_shift_time',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt_drop_default_shift_time FROM @drop_default_shift_time_sql;
|
||||
EXECUTE stmt_drop_default_shift_time;
|
||||
DEALLOCATE PREPARE stmt_drop_default_shift_time;
|
||||
|
||||
-- +goose Down
|
||||
SET @bases_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'bases'
|
||||
);
|
||||
|
||||
SET @col_default_shift_time_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'bases'
|
||||
AND column_name = 'default_shift_time'
|
||||
);
|
||||
|
||||
SET @add_default_shift_time_sql := IF(
|
||||
@bases_exists > 0 AND @col_default_shift_time_exists = 0,
|
||||
'ALTER TABLE bases ADD COLUMN default_shift_time VARCHAR(64) NULL AFTER default_shift_end',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt_add_default_shift_time FROM @add_default_shift_time_sql;
|
||||
EXECUTE stmt_add_default_shift_time;
|
||||
DEALLOCATE PREPARE stmt_add_default_shift_time;
|
||||
Reference in New Issue
Block a user