Skip validations in the oauth migration

Also enforced the presence of needed attributes of the services table on
the database level
This commit is contained in:
Dominik Sander 2014-06-14 20:00:31 +02:00
parent db968e6f4f
commit b089919490
3 changed files with 5 additions and 6 deletions

View file

@ -4,7 +4,6 @@ module Oauthable
included do |base|
attr_accessible :service_id
validates_presence_of :service_id
base.extend ClassMethods
self.class_variable_set(:@@valid_oauth_providers, :all)
end

View file

@ -1,10 +1,10 @@
class CreateServices < ActiveRecord::Migration
def change
create_table :services do |t|
t.integer :user_id
t.string :provider
t.string :name
t.text :token
t.integer :user_id, null: false
t.string :provider, null: false
t.string :name, null: false
t.text :token, null: false
t.text :secret
t.text :refresh_token
t.datetime :expires_at

View file

@ -24,7 +24,7 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration
secret: twitter_oauth_token_secret(agent)
)
agent.service_id = service.id
agent.save!
agent.save!(validate: false)
end
if agents.length > 0
puts <<-EOF.strip_heredoc