about summary refs log tree commit diff
path: root/db/migrate/20180428000000_create_block_mutes.rb
blob: 149c91a4d21780413f48234562e344f215b79c4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class CreateBlockMutes < ActiveRecord::Migration[5.0]
  def change
    create_table "block_mutes", force: :casecade do |t|
      t.integer  "account_id",        null: false
      t.integer  "target_account_id", null: false
      t.boolean  "block",             null: false
      t.datetime "created_at",        null: false
      t.datetime "updated_at",        null: false
    end

    add_column       :blocks, :block, :boolean, null: false
    execute          "ALTER TABLE blocks ADD CONSTRAINT check_mutes_on_block CHECK(block = TRUE), INHERIT block_mutes"
    Block.update_all block: true

    add_column       :mutes, :block, :boolean, null: false
    execute          "ALTER TABLE mutes ADD CONSTRAINT check_mutes_on_block CHECK(block = FALSE), INHERIT block_mutes"
    Mute.update_all block: false
  end
end