Mark plugin migrations to be able to run them separately for each plugin.
Rails migrations have a nice feature called "scope" (as described here: http://edgeguides.rubyonrails.org/engines.html#engine-setup).
This feature enables running only migrations that belong to a certain scope.
I propose using this feature in our plugins to mark plugin's migrations, so we will be able to migrate up or down only those migrations. Effectively it will enable us to uninstall every table that belonged to a plugin.
In order to use scopes, migrations should be named accordingly: [timestamp]_[migration_name].[scope].rb (the change is adding the ".scope" to filename).
Once all the migrations are named that way, we can migrate them up or down using:
# set up a plugin: rake db:migrate SCOPE=my_plugin # remove the plugin from DB: rake db:migrate SCOPE=my_plugin VERSION=0
#4 Updated by Shimon Shtein about 3 years ago
Thanks for finding the older issue - it's the same functionality I am talking about.
I think we can close the older one - this one is more informative.
This issue is about adding a generator to our framework, so the scope would be handled automatically for new migrations.
For example, by running the following command from foreman directory:
rails g plugin:migration test_migration --plugin-name=my_plugin
will generate a new migration file called 20170101000_test_migration.my_plugin.rb in plugin's db/migrate directory.