Don't use `IF (NOT) EXITS` SQL commands in upgrade scripts
This commit is contained in:
parent
dc738ec4ce
commit
6a4314120b
|
@ -1,13 +1,11 @@
|
|||
ALTER TABLE icingaweb_schema
|
||||
MODIFY COLUMN timestamp bigint unsigned NOT NULL,
|
||||
MODIFY COLUMN version varchar(64) NOT NULL,
|
||||
ADD COLUMN IF NOT EXISTS success enum('n', 'y') DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS reason text DEFAULT NULL,
|
||||
DROP CONSTRAINT IF EXISTS idx_icingaweb_schema_version,
|
||||
ADD COLUMN success enum('n', 'y') DEFAULT NULL,
|
||||
ADD COLUMN reason text DEFAULT NULL,
|
||||
ADD CONSTRAINT idx_icingaweb_schema_version UNIQUE (version);
|
||||
|
||||
UPDATE icingaweb_schema SET timestamp = timestamp * 1000, success = 'y';
|
||||
|
||||
INSERT INTO icingaweb_schema (version, timestamp, success, reason)
|
||||
VALUES('2.12.0', UNIX_TIMESTAMP() * 1000, 'y', NULL)
|
||||
ON DUPLICATE KEY UPDATE timestamp = VALUES(timestamp), success = VALUES(success), reason = VALUES(reason);
|
||||
VALUES('2.12.0', UNIX_TIMESTAMP() * 1000, 'y', NULL);
|
||||
|
|
|
@ -5,11 +5,9 @@ ALTER TABLE icingaweb_schema
|
|||
ALTER COLUMN version TYPE varchar(64),
|
||||
ADD COLUMN success boolenum DEFAULT NULL,
|
||||
ADD COLUMN reason text DEFAULT NULL,
|
||||
DROP CONSTRAINT IF EXISTS idx_icingaweb_schema_version,
|
||||
ADD CONSTRAINT idx_icingaweb_schema_version UNIQUE (version);
|
||||
|
||||
UPDATE icingaweb_schema SET timestamp = timestamp * 1000, success = 'y';
|
||||
|
||||
INSERT INTO icingaweb_schema (version, timestamp, success, reason)
|
||||
VALUES('2.12.0', EXTRACT(EPOCH FROM now()) * 1000, 'y', NULL)
|
||||
ON CONFLICT ON CONSTRAINT idx_icingaweb_schema_version DO UPDATE SET timestamp = EXCLUDED.timestamp, success = EXCLUDED.success, reason = EXCLUDED.reason;
|
||||
VALUES('2.12.0', EXTRACT(EPOCH FROM now()) * 1000, 'y', NULL);
|
||||
|
|
Loading…
Reference in New Issue