Sequel.migration do
  up do
    alter_table(:titan_requests) do
      set_column_type :request_id, String
    end
  end

  down do
    run 'UPDATE titan_requests SET request_id = NULL;'

    # NB: the conversion back from string to int needs to be done in SQL with the USING clause:
    run <<~SQL
      ALTER TABLE titan_requests ALTER COLUMN request_id TYPE integer USING request_id::integer;
    SQL
  end
end
