better migrations for unread count field on group accounts table
This commit is contained in:
parent
06e1c47ff4
commit
7bd832c9bd
|
@ -1,5 +1,10 @@
|
|||
class AddUnreadCountToGroupAccounts < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :group_accounts, :unread_count, :integer, default: 0
|
||||
def up
|
||||
add_column :group_accounts, :unread_count, :integer
|
||||
change_column_default :group_accounts, :unread_count, 0
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :group_accounts, :unread_count
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
class BackfillAddUnreadCountToGroupAccounts < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
GroupAccount.in_batches do |relation|
|
||||
relation.update_all unread_count: 0
|
||||
sleep(0.1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_07_21_214831) do
|
||||
ActiveRecord::Schema.define(version: 2019_07_21_234917) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Reference in New Issue