about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-09-01 13:41:43 -0500
committerFire Demon <firedemon@creature.cafe>2020-09-01 13:41:43 -0500
commitf52a54685a4482f4f16e411847b9bfe71690cf69 (patch)
tree7f1c122b6578befda2d6da9d232e9323e0b6a998
parent97a98796b4b01d9ce4c2147cacf54960a71010f2 (diff)
[Database] Backfill users.username column
-rw-r--r--db/migrate/20200901183004_backfill_user_username.rb11
-rw-r--r--db/schema.rb2
2 files changed, 12 insertions, 1 deletions
diff --git a/db/migrate/20200901183004_backfill_user_username.rb b/db/migrate/20200901183004_backfill_user_username.rb
new file mode 100644
index 000000000..e206aaae8
--- /dev/null
+++ b/db/migrate/20200901183004_backfill_user_username.rb
@@ -0,0 +1,11 @@
+class BackfillUserUsername < ActiveRecord::Migration[5.2]
+  def up
+    User.find_each do |user|
+      user.update!(username: user.account.username)
+    end
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 88105f462..f1ffb3c12 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2020_09_01_035527) do
+ActiveRecord::Schema.define(version: 2020_09_01_183004) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"