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]
|
class AddUnreadCountToGroupAccounts < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def up
|
||||||
add_column :group_accounts, :unread_count, :integer, default: 0
|
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
|
||||||
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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
Loading…
Reference in New Issue