migration to fix old invites for resend

This commit is contained in:
Maxwell Salzberg 2011-08-18 14:51:15 -07:00
parent 7d9b1636c0
commit 8b278adff6
2 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,19 @@
class AddIdentifierToExistingInvitations < ActiveRecord::Migration
def self.up
execute <<SQL
UPDATE invitations
SET invitations.identifier = (SELECT users.invitation_identifier FROM users WHERE users.id = invitations.recipient_id),
invitations.service = (SELECT users.invitation_service FROM users WHERE users.id = invitations.recipient_id)
WHERE invitations.identifier IS NULL
SQL
end
def self.down
execute <<SQL
UPDATE invitations
SET invitations.identifier = NULL,
invitations.service = NULL
WHERE (SELECT users.invitation_identifier FROM users WHERE users.id = invitations.recipient_id) IS NOT NULL
SQL
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110816061820) do
ActiveRecord::Schema.define(:version => 20110818212541) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false