Skip to content

Commit

Permalink
Rename CompatibleMigration -> Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Bassett committed Nov 28, 2017
1 parent 560604a commit c5fd4eb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion spec/migrations/1_create_authors_table.rb
@@ -1,4 +1,4 @@
class CreateAuthorsTable < CompatibleMigration
class CreateAuthorsTable < Migration
def change
create_table :authors do |t|
t.string :name, null: false
Expand Down
2 changes: 1 addition & 1 deletion spec/migrations/2_create_books_table.rb
@@ -1,4 +1,4 @@
class CreateBooksTable < CompatibleMigration
class CreateBooksTable < Migration
def change
create_table :books do |t|
if ActiveRecord::VERSION::STRING >= "5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/migrations/3_add_constraints.rb
@@ -1,4 +1,4 @@
class AddConstraints < CompatibleMigration
class AddConstraints < Migration
def change
add_foreign_key_constraint :books, :authors, on_delete: :cascade, index: true
add_presence_constraint :books, :title
Expand Down
2 changes: 1 addition & 1 deletion spec/migrations/4_create_books_per_author_view.rb
@@ -1,4 +1,4 @@
class CreateBooksPerAuthorView < CompatibleMigration
class CreateBooksPerAuthorView < Migration
def change
create_view(
:books_per_author,
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
@@ -1,7 +1,7 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require "rein"
require "support/compatible_migration"
require "support/migration"

MIGRATIONS_PATH = [File.expand_path("../migrations", __FILE__)].freeze

Expand Down
12 changes: 0 additions & 12 deletions spec/support/compatible_migration.rb

This file was deleted.

8 changes: 8 additions & 0 deletions spec/support/migration.rb
@@ -0,0 +1,8 @@
# Support the new rails 5 migration syntax, while retaining backwards
# compatibility with the old sytax.
Migration = # rubocop:disable Naming/ConstantName
if ActiveRecord::VERSION::STRING >= "5.0.0"
ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
else
ActiveRecord::Migration
end

0 comments on commit c5fd4eb

Please sign in to comment.