From 48392e717b195f2cb01465978ba5fed1bd2b1855 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Wed, 28 Mar 2012 03:17:02 +0200 Subject: [PATCH] migration for old invitation-emails --- ...025842_remove_invitation_email_from_users.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20120328025842_remove_invitation_email_from_users.rb diff --git a/db/migrate/20120328025842_remove_invitation_email_from_users.rb b/db/migrate/20120328025842_remove_invitation_email_from_users.rb new file mode 100644 index 000000000..c08202ce4 --- /dev/null +++ b/db/migrate/20120328025842_remove_invitation_email_from_users.rb @@ -0,0 +1,17 @@ +class RemoveInvitationEmailFromUsers < ActiveRecord::Migration + def self.up + execute <<-SQL + UPDATE users + SET email = concat('invitemail_', id, '@example.org') + WHERE invitation_token IS NOT NULL + SQL + end + + def self.down + execute <<-SQL + UPDATE users + SET email = (SELECT identifier FROM invitations WHERE invitations.recipient_id = users.id) + WHERE invitation_token IS NOT NULL + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index 1f2bfd100..763db208c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120322223517) do +ActiveRecord::Schema.define(:version => 20120328025842) do create_table "account_deletions", :force => true do |t| t.string "diaspora_handle"