20220729171123_fix_custom_filter_keywords_id_seq.rb 581 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1]
  3. disable_ddl_transaction!
  4. def up
  5. # 20220613110711 manually inserts items with set `id` in the database, but
  6. # we also need to bump the sequence number, otherwise
  7. safety_assured do
  8. execute <<-SQL.squish
  9. BEGIN;
  10. LOCK TABLE custom_filter_keywords IN EXCLUSIVE MODE;
  11. SELECT setval('custom_filter_keywords_id_seq'::regclass, id) FROM custom_filter_keywords ORDER BY id DESC LIMIT 1;
  12. COMMIT;
  13. SQL
  14. end
  15. end
  16. def down; end
  17. end