Permalink
Browse files

Merge pull request #59 from gregates/down_migrations_revised

Bugfixes for down migrations, and a rollback method
  • Loading branch information...
2 parents 9276509 + 748851e commit cd5a71ab3bc7856346f54add1aef3814a88a3eea @jcoglan jcoglan committed Aug 21, 2013
View
@@ -113,6 +113,8 @@ the gem's migrations that have not yet been applied to your database.
-> 0.0009s
...
+To rollback migrations, use <tt>Songkick::OAuth2::Model::Schema.rollback</tt>.
+
=== Model Mixins
@@ -10,6 +10,14 @@ class << self
alias :up :migrate
end
+ def self.rollback
+ ActiveRecord::Base.logger ||= Logger.new(StringIO.new)
+ ActiveRecord::Migrator.down(migrations_path)
+ end
+ class << self
+ alias :down :rollback
+ end
+
def self.migrations_path
File.expand_path('../schema', __FILE__)
end
@@ -7,7 +7,7 @@ def self.up
end
def self.down
- remove_index :oauth2_authorizations, INDEX_NAME
+ remove_index :oauth2_authorizations, :name => INDEX_NAME
add_index :oauth2_authorizations, [:client_id, :access_token_hash]
end
end
@@ -26,7 +26,7 @@ def self.down
remove_index :oauth2_clients, [:client_id]
add_index :oauth2_clients, [:client_id]
- remove_clients :oauth2_clients, [:name]
+ remove_index :oauth2_clients, [:name]
end
end

0 comments on commit cd5a71a

Please sign in to comment.