Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bugfixes for down migrations, and a rollback method #59

Merged
merged 3 commits into from

2 participants

@gregates

Tried installing this gem on a project I'm working on today. After running the database migrations, as per my usual practice, I tried rolling them back. This failed due two a couple of small bugs in the down methods for the migrations.

This pull request fixes those bugs. It also adds a ::rollback class method (aliased as ::down) to the Songkick::OAuth2::Schema class, to mirror the ::migrate class method.

@jcoglan jcoglan merged commit cd5a71a into songkick:master
@jcoglan

@gregates Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 19, 2013
  1. @gregates
  2. @gregates
  3. @gregates

    Adds ::rollback method to Songkick::Oauth2::Schema

    gregates authored
    Also updates README to indicate the availability
    of the rollback method.
    
    (Also aliased as ::down)
This page is out of date. Refresh to see the latest.
View
2  README.rdoc
@@ -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
View
8 lib/songkick/oauth2/schema.rb
@@ -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
View
2  lib/songkick/oauth2/schema/20121024180930_songkick_oauth2_schema_add_authorization_index.rb
@@ -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
View
2  lib/songkick/oauth2/schema/20121025180447_songkick_oauth2_schema_add_unique_indexes.rb
@@ -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
Something went wrong with that request. Please try again.