Project

General

Profile

Actions

Tracker #19454

open

Mark plugin migrations to be able to run them separately for each plugin.

Added by Shimon Shtein about 7 years ago. Updated almost 6 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
Category:
Plugin integration
Target version:
-
% Done:

0%

Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

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

Related issues 3 (1 open2 closed)

Related to Foreman - Feature #3588: Uninstall plugins - from GUI or command lineNew11/06/2013Actions
Has duplicate Foreman - Feature #16595: Add scoping to plugin migrations.DuplicateShimon Shtein09/18/2016Actions
Blocked by Foreman - Feature #19589: Add an option to create plugin migrations with properly marked scopeClosedShimon Shtein05/18/2017Actions
Actions

Also available in: Atom PDF