التراجع عن ترحيل المكون الإضافي

I’m working on a plugin (my first attempt at doing so).

The plugin requires extending the database with a new migration. I was able to run this initial migration using the bin/rake db:migrate command.

I noticed some problems with the migration afterwards, and am trying to rollback the database, then edit and re-run the migration.

However, when I run bin/rake db:rollback, I’m getting the following error:

rake aborted!
ActiveRecord::UnknownMigrationVersionError: 

No migration with version number 20210820205029.

The version number in the error message does correspond with the plugin migration I’m working on.

Any ideas?

إعجابَين (2)

Yeah, you can’t currently rollback migrations in plugin directories. The way I do it is move the migration to the core repo
mv plugins/discourse-example/db/migrate/20210823160357_migration.rb db/migrate/20210823160357_migration.rb

rollback, and then move it back to the plugin
mv db/migrate/20210823160357_migration.rb plugins/discourse-example/db/migrate/20210823160357_migration.rb

If your migration isn’t the last migration in the core db directory, you can use bin/rails db:migrate:down VERSION=20210823160357 to target the migration you just moved.

6 إعجابات

Nice lifehack, thanks!