discourse/db/migrate/20180521175611_change_indexes_topic_view_item.rb
Guo Xiang Tan a6e9f4f44b FIX: DROP NOT NULL instead of changing all the rows in the table.
```
change_column :topic_views, :ip_address, :inet, null: true
```

translates to

```
"ALTER TABLE \"topic_views\" ALTER COLUMN \"ip_address\" TYPE inet"
```

which locks the whole table while the migration is taking place.
2018-07-17 11:03:41 +08:00

17 lines
368 B
Ruby

class ChangeIndexesTopicViewItem < ActiveRecord::Migration[5.1]
def up
remove_index :topic_views,
column: [:ip_address, :topic_id],
name: :ip_address_topic_id_topic_views,
unique: true
remove_index :topic_views,
column: [:user_id, :topic_id],
name: :user_id_topic_id_topic_views,
unique: true
end
def down
end
end