Skip to content

Commit d233399

Browse files
authored
Adapt to changed migration-shared-context (#3765)
1 parent 8b09b51 commit d233399

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spec/migrations/20240314131908_add_user_guid_to_jobs_table_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
describe 'jobs table' do
1010
it 'adds a column `user_guid`' do
1111
expect(db[:jobs].columns).not_to include(:user_guid)
12-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error
12+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error
1313
expect(db[:jobs].columns).to include(:user_guid)
1414
end
1515

1616
it 'adds an index on the user_guid column' do
1717
expect(db.indexes(:jobs)).not_to include(:jobs_user_guid_index)
18-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error
18+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error
1919
expect(db.indexes(:jobs)).to include(:jobs_user_guid_index)
2020
end
2121

@@ -27,13 +27,13 @@
2727

2828
it 'does not fail' do
2929
expect(db[:jobs].columns).to include(:user_guid)
30-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error
30+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error
3131
end
3232

3333
it 'continues to create the index' do
3434
expect(db[:jobs].columns).to include(:user_guid)
3535
expect(db.indexes(:jobs)).not_to include(:jobs_user_guid_index)
36-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error
36+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error
3737
expect(db.indexes(:jobs)).to include(:jobs_user_guid_index)
3838
end
3939
end
@@ -46,43 +46,43 @@
4646

4747
it 'does not fail' do
4848
expect(db.indexes(:jobs)).to include(:jobs_user_guid_index)
49-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true) }.not_to raise_error
49+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error
5050
end
5151
end
5252
end
5353

5454
describe 'idempotency of down' do
5555
context 'index does not exist' do
5656
before do
57-
Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true)
57+
Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true)
5858
db.drop_index :jobs, :user_guid, name: :jobs_user_guid_index
5959
end
6060

6161
it 'does not fail' do
6262
expect(db[:jobs].columns).to include(:user_guid)
6363
expect(db.indexes(:jobs)).not_to include(:jobs_user_guid_index)
64-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true, target: 0) }.not_to raise_error
64+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index - 1, allow_missing_migration_files: true) }.not_to raise_error
6565
end
6666

6767
it 'continues to remove the `user_guid` column' do
6868
expect(db[:jobs].columns).to include(:user_guid)
6969
expect(db.indexes(:jobs)).not_to include(:jobs_user_guid_index)
70-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true, target: 0) }.not_to raise_error
70+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index - 1, allow_missing_migration_files: true) }.not_to raise_error
7171
expect(db[:jobs].columns).not_to include(:user_guid)
7272
end
7373
end
7474

7575
context 'index and column do not exist' do
7676
before do
77-
Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true)
77+
Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true)
7878
db.drop_index :jobs, :user_guid, name: :jobs_user_guid_index
7979
db.drop_column :jobs, :user_guid
8080
end
8181

8282
it 'does not fail' do
8383
expect(db[:jobs].columns).not_to include(:user_guid)
8484
expect(db.indexes(:jobs)).not_to include(:jobs_user_guid_index)
85-
expect { Sequel::Migrator.run(db, migration_to_test, allow_missing_migration_files: true, target: 0) }.not_to raise_error
85+
expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index - 1, allow_missing_migration_files: true) }.not_to raise_error
8686
end
8787
end
8888
end

0 commit comments

Comments
 (0)