Initial commit
This commit is contained in:
15
db/migrate/20181017114624_enumerize_wallet_kind.rb
Normal file
15
db/migrate/20181017114624_enumerize_wallet_kind.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class EnumerizeWalletKind < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
id_kind_hash = Wallet.pluck(:id, :kind).to_h
|
||||
|
||||
remove_column :wallets, :kind
|
||||
add_column :wallets, :kind, :integer, limit: 4, null: false, after: :address
|
||||
|
||||
Wallet.find_each { |w| w.update!(kind: id_kind_hash[w.id]) }
|
||||
|
||||
add_index :wallets, :status
|
||||
add_index :wallets, :kind
|
||||
add_index :wallets, :currency_id
|
||||
add_index :wallets, %i[kind currency_id status]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user