about summary refs log tree commit diff
path: root/db/post_migrate/20220310060614_optimize_null_index_media_attachments_scheduled_status_id.rb
blob: 9d86a0364b4796179032756e91fb82d7557d3588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

require Rails.root.join('lib', 'mastodon', 'migration_helpers')

class OptimizeNullIndexMediaAttachmentsScheduledStatusId < ActiveRecord::Migration[5.2]
  include Mastodon::MigrationHelpers

  disable_ddl_transaction!

  def up
    update_index :media_attachments, 'index_media_attachments_on_scheduled_status_id', :scheduled_status_id, where: 'scheduled_status_id IS NOT NULL'
  end

  def down
    update_index :media_attachments, 'index_media_attachments_on_scheduled_status_id', :scheduled_status_id
  end
end