1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00
phorge-phorge/resources/sql/autopatches/20180124.herald.01.repetition.sql
epriestley fd49acd033 Fix Herald repetition policy migration for NULL
When we change a nullable column to a non-nullable column, we can get a
data truncation error if any value was "NULL".

This is exceptionally unusual, but our two very oldest Herald rules have
a "NULL" policy on `secure`.
2018-01-26 13:17:15 -08:00

26 lines
708 B
SQL

/* This column was previously "uint32?" with these values:
1: run every time
0: run only the first time
*/
UPDATE {$NAMESPACE}_herald.herald_rule
SET repetitionPolicy = '1'
WHERE repetitionPolicy IS NULL;
ALTER TABLE {$NAMESPACE}_herald.herald_rule
CHANGE repetitionPolicy
repetitionPolicy VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
/* If the old value was "0", the new value is "first". */
UPDATE {$NAMESPACE}_herald.herald_rule
SET repetitionPolicy = 'first'
WHERE repetitionPolicy = '0';
/* If the old value was anything else, the new value is "every". */
UPDATE {$NAMESPACE}_herald.herald_rule
SET repetitionPolicy = 'every'
WHERE repetitionPolicy NOT IN ('first', '0');