database_tasks_extensions.rb 503 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. require_relative '../mastodon/snowflake'
  3. module ActiveRecord
  4. module Tasks
  5. module DatabaseTasks
  6. original_load_schema = instance_method(:load_schema)
  7. define_method(:load_schema) do |db_config, *args|
  8. ActiveRecord::Base.establish_connection(db_config)
  9. Mastodon::Snowflake.define_timestamp_id
  10. original_load_schema.bind(self).call(db_config, *args)
  11. Mastodon::Snowflake.ensure_id_sequences_exist
  12. end
  13. end
  14. end
  15. end