exports.up = (pgm) => { pgm.sql(` -- Nullable timestamp rather than a boolean: disabling is reversible, and -- this records when it happened without a second column. ALTER TABLE customers ADD COLUMN IF NOT EXISTS disabled_at TIMESTAMPTZ; -- attachCustomer joins customers on every authenticated request to check -- this, so the lookup wants an index on the active case. CREATE INDEX IF NOT EXISTS customers_disabled_at_idx ON customers (disabled_at) WHERE disabled_at IS NOT NULL; `); }; exports.down = (pgm) => { pgm.sql(` DROP INDEX IF EXISTS customers_disabled_at_idx; ALTER TABLE customers DROP COLUMN IF EXISTS disabled_at; `); };