Skip to content

Commit

Permalink
Update temporary table names used for the migrations runner specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed May 1, 2022
1 parent d561270 commit 1054dcb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
34 changes: 17 additions & 17 deletions spec/marten/db/management/migrations/runner_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector
Marten::DB::Management::SchemaEditor.run_for(Marten::DB::Connection.default) do |schema_editor|
schema_editor.delete_table("foo_tags") if introspector.table_names.includes?("foo_tags")
schema_editor.delete_table("bar_tags") if introspector.table_names.includes?("bar_tags")
schema_editor.delete_table("runner_spec_foo_tags") if introspector.table_names.includes?("runner_spec_foo_tags")
schema_editor.delete_table("runner_spec_bar_tags") if introspector.table_names.includes?("runner_spec_bar_tags")
end

# Reset local migration app configs to avoid them to be used elsewhere.
Expand All @@ -34,8 +34,8 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector
Marten::DB::Management::SchemaEditor.run_for(Marten::DB::Connection.default) do |schema_editor|
schema_editor.delete_table("foo_tags") if introspector.table_names.includes?("foo_tags")
schema_editor.delete_table("bar_tags") if introspector.table_names.includes?("bar_tags")
schema_editor.delete_table("runner_spec_foo_tags") if introspector.table_names.includes?("runner_spec_foo_tags")
schema_editor.delete_table("runner_spec_bar_tags") if introspector.table_names.includes?("runner_spec_bar_tags")
end
end

Expand All @@ -61,12 +61,12 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("foo_tags").should be_true
columns_details = introspector.columns_details("foo_tags")
introspector.table_names.includes?("runner_spec_foo_tags").should be_true
columns_details = introspector.columns_details("runner_spec_foo_tags")
columns_details.map(&.name).sort!.should eq ["active", "id", "label"]

introspector.table_names.includes?("bar_tags").should be_true
columns_details = introspector.columns_details("bar_tags")
introspector.table_names.includes?("runner_spec_bar_tags").should be_true
columns_details = introspector.columns_details("runner_spec_bar_tags")
columns_details.map(&.name).sort!.should eq ["active", "id", "label"]
end

Expand All @@ -86,8 +86,8 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("bar_tags").should be_true
columns_details = introspector.columns_details("bar_tags")
introspector.table_names.includes?("runner_spec_bar_tags").should be_true
columns_details = introspector.columns_details("runner_spec_bar_tags")
columns_details.map(&.name).sort!.should eq ["id", "label"]
end

Expand All @@ -112,8 +112,8 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("foo_tags").should be_false
introspector.table_names.includes?("bar_tags").should be_false
introspector.table_names.includes?("runner_spec_foo_tags").should be_false
introspector.table_names.includes?("runner_spec_bar_tags").should be_false
end

it "is able to fake a specific migration forward" do
Expand All @@ -133,7 +133,7 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("bar_tags").should be_false
introspector.table_names.includes?("runner_spec_bar_tags").should be_false
end

it "marks replacement migrations as applied if the replaced migrations were applied during the runner execution" do
Expand All @@ -147,7 +147,7 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("foo_tags").should be_true
introspector.table_names.includes?("runner_spec_foo_tags").should be_true
end

it "marks replacement migrations as applied if the replaced migrations were applied before the runner execution" do
Expand Down Expand Up @@ -191,7 +191,7 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("bar_tags").should be_false
introspector.table_names.includes?("runner_spec_bar_tags").should be_false
end

it "is able to unapply the migrations of a specific app up to a specific version" do
Expand All @@ -212,8 +212,8 @@ describe Marten::DB::Management::Migrations::Runner do

introspector = Marten::DB::Connection.default.introspector

introspector.table_names.includes?("bar_tags").should be_true
columns_details = introspector.columns_details("bar_tags")
introspector.table_names.includes?("runner_spec_bar_tags").should be_true
columns_details = introspector.columns_details("runner_spec_bar_tags")
columns_details.map(&.name).sort!.should eq ["id", "label"]
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Migration::RunnerSpec::BarApp::V202108092226111 < Marten::Migration
depends_on "runner_spec_foo_app", "202108092226111_auto"

def plan
create_table :bar_tags do
create_table :runner_spec_bar_tags do
column :id, :big_int, primary_key: true, auto: true
column :label, :string, max_size: 255, unique: true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Migration::RunnerSpec::BarApp::V202108092226112 < Marten::Migration
depends_on "runner_spec_bar_app", "202108092226111_auto"

def plan
add_column :bar_tags, :active, :bool, default: true
add_column :runner_spec_bar_tags, :active, :bool, default: true
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Migration::RunnerSpec::FooApp::V202108092226111 < Marten::Migration
def plan
create_table :foo_tags do
create_table :runner_spec_foo_tags do
column :id, :big_int, primary_key: true, auto: true
column :label, :string, max_size: 255, unique: true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Migration::RunnerSpec::FooApp::V202108092226112 < Marten::Migration
depends_on "runner_spec_foo_app", "202108092226111_auto"

def plan
add_column :foo_tags, :active, :bool, default: true
add_column :runner_spec_foo_tags, :active, :bool, default: true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Migration::RunnerSpec::FooApp::V202108092226113 < Marten::Migration
replaces "runner_spec_foo_app", "202108092226112_auto"

def plan
create_table :foo_tags do
create_table :runner_spec_foo_tags do
column :id, :big_int, primary_key: true, auto: true
column :label, :string, max_size: 255, unique: true
column :active, :bool, default: true
Expand Down

0 comments on commit 1054dcb

Please sign in to comment.