Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorcmrd Senya <senya@riseup.net>2018-05-03 19:44:32 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2018-05-03 22:31:29 +0300
commitcb294fd3f4a856b7ef2f503268061fd340265ef2 (patch)
tree95d2c67160b63f3f993e5a46a911a1213ee122f6 /db
parente9f6dbdffd8b9c74238e1183cff3918a487e4a89 (diff)
Add completed_at to account_migrations
Use completed_at datetime field as an indication of a performed migration closes #7805
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180430134444_add_completed_at_to_account_migration.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20180430134444_add_completed_at_to_account_migration.rb b/db/migrate/20180430134444_add_completed_at_to_account_migration.rb
new file mode 100644
index 000000000..13eff4c85
--- /dev/null
+++ b/db/migrate/20180430134444_add_completed_at_to_account_migration.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddCompletedAtToAccountMigration < ActiveRecord::Migration[5.1]
+ def change
+ add_column :account_migrations, :completed_at, :datetime, default: nil
+
+ reversible do |change|
+ change.up do
+ set_completed_at_for_closed_accounts
+ end
+ end
+ end
+
+ def set_completed_at_for_closed_accounts
+ # rubocop:disable Rails/SkipsModelValidations
+ AccountMigration.joins(:old_person).where(people: {closed_account: true}).update_all(completed_at: Time.zone.now)
+ # rubocop:enable Rails/SkipsModelValidations
+ end
+end