|
3 | 3 |
|
4 | 4 | RSpec.describe 'migration to add user column to processes table', isolation: :truncation, type: :migration do |
5 | 5 | include_context 'migration' do |
6 | | - let(:migration_filename) { '20250610212414_add_action_user_to_processes.rb' } |
| 6 | + let(:migration_filename) { '20250610212414_add_user_to_processes.rb' } |
7 | 7 | end |
8 | 8 |
|
9 | 9 | describe 'processes table' do |
10 | 10 | it 'adds a column `user`' do |
11 | | - expect(db[:processes].columns).not_to include(:action_user) |
| 11 | + expect(db[:processes].columns).not_to include(:user) |
12 | 12 | expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error |
13 | | - expect(db[:processes].columns).to include(:action_user) |
| 13 | + expect(db[:processes].columns).to include(:user) |
14 | 14 | end |
15 | 15 |
|
16 | 16 | describe 'idempotency of up' do |
17 | 17 | context '`user` column already exists' do |
18 | 18 | before do |
19 | | - db.add_column :processes, :action_user, String, size: 255 |
| 19 | + db.add_column :processes, :user, String, size: 255 |
20 | 20 | end |
21 | 21 |
|
22 | 22 | it 'does not fail' do |
23 | | - expect(db[:processes].columns).to include(:action_user) |
| 23 | + expect(db[:processes].columns).to include(:user) |
24 | 24 | expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) }.not_to raise_error |
25 | 25 | end |
26 | 26 | end |
|
33 | 33 | end |
34 | 34 |
|
35 | 35 | it 'continues to remove the `user_guid` column' do |
36 | | - expect(db[:processes].columns).to include(:action_user) |
| 36 | + expect(db[:processes].columns).to include(:user) |
37 | 37 | expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index - 1, allow_missing_migration_files: true) }.not_to raise_error |
38 | | - expect(db[:processes].columns).not_to include(:action_user) |
| 38 | + expect(db[:processes].columns).not_to include(:user) |
39 | 39 | end |
40 | 40 | end |
41 | 41 |
|
42 | 42 | context 'column does not exist' do |
43 | 43 | before do |
44 | 44 | Sequel::Migrator.run(db, migrations_path, target: current_migration_index, allow_missing_migration_files: true) |
45 | | - db.drop_column :processes, :action_user |
| 45 | + db.drop_column :processes, :user |
46 | 46 | end |
47 | 47 |
|
48 | 48 | it 'does not fail' do |
49 | | - expect(db[:processes].columns).not_to include(:action_user) |
| 49 | + expect(db[:processes].columns).not_to include(:user) |
50 | 50 | expect { Sequel::Migrator.run(db, migrations_path, target: current_migration_index - 1, allow_missing_migration_files: true) }.not_to raise_error |
51 | 51 | end |
52 | 52 | end |
|
0 commit comments