Make latest migration postgres compatible
This commit is contained in:
parent
834c75894c
commit
32368a16dd
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
class AddIdentifierToExistingInvitations < ActiveRecord::Migration
|
class AddIdentifierToExistingInvitations < ActiveRecord::Migration
|
||||||
|
class Invitation < ActiveRecord::Base; end
|
||||||
def self.up
|
def self.up
|
||||||
execute <<SQL
|
execute <<SQL unless Invitation.count == 0
|
||||||
UPDATE invitations
|
UPDATE invitations
|
||||||
SET invitations.identifier = (SELECT users.invitation_identifier FROM users WHERE users.id = invitations.recipient_id),
|
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)
|
invitations.service = (SELECT users.invitation_service FROM users WHERE users.id = invitations.recipient_id)
|
||||||
|
|
@ -9,7 +10,7 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
execute <<SQL
|
execute <<SQL unless Invitation.count == 0
|
||||||
UPDATE invitations
|
UPDATE invitations
|
||||||
SET invitations.identifier = NULL,
|
SET invitations.identifier = NULL,
|
||||||
invitations.service = NULL
|
invitations.service = NULL
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue