MibMigrator
The MibMigrator is a tool that allows adding new migrations to an existing migration project, or invoking a migration library.
Installation
Starting with MIB v5.0, MibMigrator is now distributed as a dotnet tool, available as a NuGet packaging, which allows easier installation and update.
To install, you can run the following command in a terminal:
dotnet tool install -g MediaiBox.Tools.Migrator --version 5.0.0
This will install MibMigrator globally, and you can execute it anywhere. But if one needs to distribute this for a customer, we recommend installing it to a specific path, which can then be packaged.
For more information about dotnet tool install, please check Microsoft's documentation here.
Updating
As with any other dotnet tool, updating to the newest version just requires running the following command:
dotnet tool update MediaiBox.Tools.Migrator --version 5.0.1
A MibMigrator that was installed to a specific path can also be updated using the correct path parameter.
For more information about dotnet tool update, please check Microsoft's documentation here.
Usage
Starting with MIB v5.0, MibMigrator already includes all MIB's default migrations for the same version (ex: if MibMigrator v5.0.2 is installed, it includes version 5.0.2 of the migrations).
You can invoke MIB's default migrations using only the dll filename, without a path. For example, to run MediaiBox.Core.Database.Migrations, you can use:
mibmigrator -assembly="MediaiBox.Core.Database.Migrations.dll" -configPath="<myConfigPath>"
For custom migrations, the -assembly parameter still allows the full path for a migration dll.
Command options
For view the command options just type mibmigrator in your console. The available options will be displayed. Example:
Possible parameters:
-action="invoke/add" (optional, when ommited, the default 'invoke' action os operated)
Invoke parameters
-assembly="PATH_TO_MIGRATIONS_DLL" (required)
-configPath="PATH_TO_MIBCONFIGPATH" (optional if there's a CONFIG path under the executable folder)
-target="TARGET_MIGRATION_NAME_OR_HEAD" (optional, default value is HEAD when rollbackLabel is ommited)
-label="label_name_for_this_execution" (optional, default value is utc_20230424)
-rollbackLabel="label_name_for_rollback" (optional, when ommited, operation will follow the 'target' property)
-section="default" (optional, if ommited, uses the 'default' section of MibDatabaseConfig)
-script="PATH_TO_A_SCRIPT_FILE" (optional, just in case of scripting instead of migrating)
-ignoreUnsupportedOperation (optional)
-rollbacktarget (optional). To set it to the initial state, use it with "auto". Example: -rollbacktarget="auto"
-logInformation=quiet (no show any log) | minimal (show only log) *default | detailed (show log and verbose) | diagnostic (show log,verbose,errorLog and exception)
AddMigration parameters
-projectPath="PATH_TO_.CSPROJ_FILE" (required)
-migrationName="MIGRATION_NAME" (required)
News - Mib6.0
From version 6.0 onwards, MibMigrator will also be distributed as a Docker Image, enabling more usability in non-development environments.
Example of use
- To execute a default migration just use a command similar to the one proposed:
docker run --rm --network host -v /$(pwd)/Config:/Config mibmigrator:latest -assembly=MediaiBox.Core.Database.Migrations.dll -configPath=/Config
Important
--network
Indicates that the container will use the same network as the host.
-v
A volume must be provided containing the configuration files necessary to run the tool. Are they:
- MibConfigurableObjectConfig.mibconfig
- MibDatabaseConfig.mibconfig
- MibLogConfig.mibconfig
- MibObjectCacheConfig.mibconfig
The -configPath parameter must always be entered for MibMigrator, pointing to the created volume.
- To execute a custom migration just use a command similar to the one proposed:
docker run --rm --network host -v /$(pwd)/Config:/Config -v/$(pwd)/Custom:/Custom mibmigrator:latest -assembly=/Custom/MediaiBox.Tools.Migrator.TestLibrary.Test.MibDatabaseMigrations.dll -configPath=/Config
Important
--network
Indicates that the container will use the same network as the host.
-v
In addition to the volume referring to the configurations, a volume must be provided for the directory that contains the customized migrations.
Remember to enter the path to the created volume in the -assembly parameter.