File tree 3 files changed +36
-1
lines changed
railties/test/application/rake
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ * Fix ` bin/rails db:forward ` first migration.
2
+
3
+ * bogdanvlviv*
4
+
1
5
* Support Descending Indexes for MySQL.
2
6
3
7
MySQL 8.0.1 and higher supports descending indexes: ` DESC ` in an index definition is no longer ignored.
Original file line number Diff line number Diff line change @@ -1104,7 +1104,13 @@ def migration_files(paths)
1104
1104
1105
1105
def move ( direction , migrations_paths , steps )
1106
1106
migrator = new ( direction , migrations ( migrations_paths ) )
1107
- start_index = migrator . migrations . index ( migrator . current_migration )
1107
+
1108
+ start_index =
1109
+ if current_version == 0
1110
+ 0
1111
+ else
1112
+ migrator . migrations . index ( migrator . current_migration )
1113
+ end
1108
1114
1109
1115
if start_index
1110
1116
finish = migrator . migrations [ start_index + steps ]
Original file line number Diff line number Diff line change @@ -142,6 +142,31 @@ class AMigration < ActiveRecord::Migration::Current
142
142
end
143
143
end
144
144
145
+ test "migration status after rollback and forward" do
146
+ Dir . chdir ( app_path ) do
147
+ `bin/rails generate model user username:string password:string;
148
+ bin/rails generate migration add_email_to_users email:string;
149
+ bin/rails db:migrate`
150
+
151
+ output = `bin/rails db:migrate:status`
152
+
153
+ assert_match ( /up\s +\d {14}\s +Create users/ , output )
154
+ assert_match ( /up\s +\d {14}\s +Add email to users/ , output )
155
+
156
+ `bin/rails db:rollback STEP=2`
157
+ output = `bin/rails db:migrate:status`
158
+
159
+ assert_match ( /down\s +\d {14}\s +Create users/ , output )
160
+ assert_match ( /down\s +\d {14}\s +Add email to users/ , output )
161
+
162
+ `bin/rails db:forward STEP=2`
163
+ output = `bin/rails db:migrate:status`
164
+
165
+ assert_match ( /up\s +\d {14}\s +Create users/ , output )
166
+ assert_match ( /up\s +\d {14}\s +Add email to users/ , output )
167
+ end
168
+ end
169
+
145
170
test "migration status after rollback and redo without timestamps" do
146
171
add_to_config ( "config.active_record.timestamped_migrations = false" )
147
172
You can’t perform that action at this time.
0 commit comments