about summary refs log tree commit diff
path: root/lib/active_record
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-03-19 13:57:15 +0100
committerClaire <claire.github-309c@sitedethib.com>2021-03-19 13:57:15 +0100
commit3ad6ef72cb3a02135a0f395a8a46323e86c4b334 (patch)
treeff1f1d15a80f5420c52afd4d975b44c0afe1194e /lib/active_record
parentba22398c38067e05f141a0dddeb20bf68913988a (diff)
parent741d0952b174740e70a09fe6db6862624dfe1e44 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'lib/active_record')
-rw-r--r--lib/active_record/database_tasks_extensions.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/active_record/database_tasks_extensions.rb b/lib/active_record/database_tasks_extensions.rb
new file mode 100644
index 000000000..e274f476d
--- /dev/null
+++ b/lib/active_record/database_tasks_extensions.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require_relative '../mastodon/snowflake'
+
+module ActiveRecord
+  module Tasks
+    module DatabaseTasks
+      original_load_schema = instance_method(:load_schema)
+
+      define_method(:load_schema) do |db_config, *args|
+        ActiveRecord::Base.establish_connection(db_config)
+        Mastodon::Snowflake.define_timestamp_id
+
+        original_load_schema.bind(self).call(db_config, *args)
+
+        Mastodon::Snowflake.ensure_id_sequences_exist
+      end
+    end
+  end
+end