-- Migration: normalize legacy '0' placeholders to NULL
--
-- The original PHP system stored '0' in bank_id and appliance_id for
-- "nothing selected" instead of leaving the field blank. '0' was never a
-- real row in either master table, so any edit-and-save on an affected
-- record fails with a foreign key violation the moment you try to save it
-- (bank_id: 597 records, appliance_id: 829 records, as of the original
-- import). NULL is what these fields should have held all along, and it's
-- what an unset field actually means elsewhere in this app.
--
-- Safe to run more than once -- once a row is NULL, the WHERE clause no
-- longer matches it.
UPDATE cwsn SET bank_id = NULL WHERE bank_id = '0';
UPDATE cwsn SET appliance_id = NULL WHERE appliance_id = '0';
