|
9 | 9 | describe 'jobs table' do
|
10 | 10 | it 'adds a column `user_guid`' do
|
11 | 11 | 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 |
13 | 13 | expect(db[:jobs].columns).to include(:user_guid)
|
14 | 14 | end
|
15 | 15 |
|
16 | 16 | it 'adds an index on the user_guid column' do
|
17 | 17 | 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 |
19 | 19 | expect(db.indexes(:jobs)).to include(:jobs_user_guid_index)
|
20 | 20 | end
|
21 | 21 |
|
|
27 | 27 |
|
28 | 28 | it 'does not fail' do
|
29 | 29 | 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 |
31 | 31 | end
|
32 | 32 |
|
33 | 33 | it 'continues to create the index' do
|
34 | 34 | expect(db[:jobs].columns).to include(:user_guid)
|
35 | 35 | 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 |
37 | 37 | expect(db.indexes(:jobs)).to include(:jobs_user_guid_index)
|
38 | 38 | end
|
39 | 39 | end
|
|
46 | 46 |
|
47 | 47 | it 'does not fail' do
|
48 | 48 | 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 |
50 | 50 | end
|
51 | 51 | end
|
52 | 52 | end
|
53 | 53 |
|
54 | 54 | describe 'idempotency of down' do
|
55 | 55 | context 'index does not exist' do
|
56 | 56 | 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) |
58 | 58 | db.drop_index :jobs, :user_guid, name: :jobs_user_guid_index
|
59 | 59 | end
|
60 | 60 |
|
61 | 61 | it 'does not fail' do
|
62 | 62 | expect(db[:jobs].columns).to include(:user_guid)
|
63 | 63 | 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 |
65 | 65 | end
|
66 | 66 |
|
67 | 67 | it 'continues to remove the `user_guid` column' do
|
68 | 68 | expect(db[:jobs].columns).to include(:user_guid)
|
69 | 69 | 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 |
71 | 71 | expect(db[:jobs].columns).not_to include(:user_guid)
|
72 | 72 | end
|
73 | 73 | end
|
74 | 74 |
|
75 | 75 | context 'index and column do not exist' do
|
76 | 76 | 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) |
78 | 78 | db.drop_index :jobs, :user_guid, name: :jobs_user_guid_index
|
79 | 79 | db.drop_column :jobs, :user_guid
|
80 | 80 | end
|
81 | 81 |
|
82 | 82 | it 'does not fail' do
|
83 | 83 | expect(db[:jobs].columns).not_to include(:user_guid)
|
84 | 84 | 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 |
86 | 86 | end
|
87 | 87 | end
|
88 | 88 | end
|
|
0 commit comments