]> cat aescling's git repositories - mastodon.git/commitdiff
Fix crash when adding a new filter (#18894)
authorClaire <claire.github-309c@sitedethib.com>
Sat, 27 Aug 2022 15:41:20 +0000 (17:41 +0200)
committeraescling <aescling+gitlab@cat.family>
Mon, 5 Sep 2022 04:28:02 +0000 (00:28 -0400)
Fixes #18742

db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb [new file with mode: 0644]

diff --git a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb
new file mode 100644 (file)
index 0000000..7ed34a3
--- /dev/null
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1]
+  disable_ddl_transaction!
+
+  def up
+    # 20220613110711 manually inserts items with set `id` in the database, but
+    # we also need to bump the sequence number, otherwise 
+    safety_assured do
+      execute <<-SQL.squish
+        BEGIN;
+        LOCK TABLE custom_filter_keywords IN EXCLUSIVE MODE;
+        SELECT setval('custom_filter_keywords_id_seq'::regclass, id) FROM custom_filter_keywords ORDER BY id DESC LIMIT 1;
+        COMMIT;
+      SQL
+    end
+  end
+
+  def down; end
+end