Table of Contents

MibBulkMigrator

The MibBulkMigrator it is a tool that allows unifying various migration sources for the creation/update of a MIB environment.

Installation

Starting with MIB v6.0, MibBulkMigrator 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.BulkMigrator --version 6.0.0

This will install MibBulkMigrator 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.BulkMigrator --version 6.0.1

A MibBulkMigrator 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.


How does it work?

When calling the MibBulkMigrator, three parameters can be specified: -configPath, -direction, -packages.Let's explore each of them in more detail:

  • configPath: Path that should contain the necessary configurations for executing the MibMigrator tool. *required
  • direction: Specifies the execution direction of the configured migrations. *required
  • packages: Specifies the list of packages to be considered during execution.

Example of usage: mibbulkmigrator -configPath=./config -direction=up -packages=1,2,3.

Tip

The MibBulkMigrator also uses the -configPath directory to apply the existing MibLogConfig there, allowing its storage/viewing to be configured.

How to configure the migrations to be executed?

For this, we create a configuration file called MibBulkMigratorConfig.mibconfig. Through this configuration, it is possible to define everything needed for the execution of the migrations. Let's take a look at its structure:

<?xml version="1.0" encoding="UTF-8"?>
<config>
	<default>
		<nugetLocalPath></nugetLocalPath>
		<nugetUrl></nugetUrl>
		<mibMigratorVersion></mibMigratorVersion>
	</default>
	<migrationPackages>
		<package>
			<id></id>
			<name></name>
			<description></description>
			<nuget>
				<name></name>
				<url></url>
				<credentials>
					<username></username>
					<pass></pass>
				</credentials>
			</nuget>
			<mibMigratorVersion></mibMigratorVersion>
			<mibDatabaseConfig>
				<type></type>
				<server></server>
				<database></database>
				<username></username>
				<password></password>
				<port></port>
				<timeout></timeout>
			</mibDatabaseConfig>
			<migrations>
				<migration>
					<packageId></packageId>
					<packageVersion></packageVersion>
					<assembly></assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
			</migrations>
		</package>
	</migrationPackages>
</config>

Let's go through each configuration block:

Default

  • nugetLocalPath: Path where the MibBulkMigratorConfig.mibconfig configuration file should be located.
  • nugetUrl: NuGet URL to fetch the versions of MibMigrator.
  • mibMigratorVersion: The version of MibMigrator that should be used.

MigrationPackages

package: List of information about the packages to be executed.

Package

  • id: Package identifier, which can be used in the -packages option when calling the mibbulkmigrator command.
  • name: Identifier of the package.
  • disable Indicates whether the package should be considered in the execution.
  • description: Description of the package.
  • nuget: Specific NuGet details to be used for this package.
  • mibMigratorVersion: Specific version of MibMigrator to be used for this package.
  • mibDatabaseConfig: Configuration for database access details where the migrations should be applied.
  • migrations: List of migrations contained in the package.

Nuget

  • name: NuGet package name.
  • url: URL to access the NuGet repository.
  • credentials: Credentials to access the NuGet repository (username and pass).

MibDatabaseConfig

Follow the guidance in this section.

Migrations

List of migrations.

Migration

  • packageId: Package identifier.
  • packageVersion: Migration version, indicating which version of MibMigrator should be used.
  • assembly: Migration assembly file name.

Up / Down

  • beforeSQL: SQL script path that should be applied before the execution of the migration.
  • target: Target of the migration.
  • afterSQL: SQL script path that should be applied after the execution of the migration.
Tip

When the "up" command is executed, the Migration it is executed in the order they were arranged in the configuration file. When the "down" command is executed, the Migration it is executed in the reverse order of the configuration.

MibBulkMigratorConfig Example

<?xml version="1.0" encoding="UTF-8"?>
<config>
	<default>
		<nugetLocalPath>./config</nugetLocalPath>
		<nugetUrl>https://nuget.agilesvcs.com/v3/index.json</nugetUrl>
		<mibMigratorVersion>6.0.41</mibMigratorVersion>
	</default>
	<migrationPackages>
		<package>
			<id>1</id>
			<name>DMM</name>
			<disable>true</disable>
			<description>DMM Database Migrations</description>
			<nuget>
				<name>AgileContent</name>
				<url>https://nuget.agilesvcs.com/v3/index.json</url>
				<credentials>
					<username>me</username>
					<pass>mePass</pass>
				</credentials>
			</nuget>
			<mibMigratorVersion>6.0.33</mibMigratorVersion>
			<mibDatabaseConfig>
				<type>sql2005</type>
				<server>127.0.0.1</server>
				<database>dmm1</database>
				<username>sa</username>
				<password>myDatabasePassword</password>
				<timeout>30</timeout>
				<port>1433</port>
			</mibDatabaseConfig>
			<migrations>
				<migration>
					<packageId>MediaiBox.Dmm.Database.Migrations</packageId>
					<packageVersion>6.0.11</packageVersion>
					<assembly>MediaiBox.Dmm.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
			</migrations>
		</package>
		<package>
			<id>2</id>
			<name>Frontend</name>
			<description>Frontend Database Migrations</description>
			<nuget>
				<name>AgileContent</name>
				<url>https://nuget.agilesvcs.com/v3/index.json</url>
				<credentials>
					<username>me</username>
					<pass>mePass</pass>
				</credentials>
			</nuget>
			<mibMigratorVersion>6.0.41</mibMigratorVersion>
			<mibDatabaseConfig>
				<type>sql2005</type>
				<server>127.0.0.1</server>
				<database>front1</database>
				<username>sa</username>
				<password>myDatabasePassword</password>
				<port>1433</port>
				<timeout>30</timeout>
			</mibDatabaseConfig>
			<migrations>
				<migration>
					<packageId>MediaiBox.Core.Database.Migrations</packageId>
					<packageVersion>6.0.41</packageVersion>
					<assembly>MediaiBox.Core.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target>201705220000000_Mib_FirstMigration</target>
						<afterSQL></afterSQL>
					</down>
				</migration>
				<migration>
					<packageId>MediaiBox.Cms.FrontEnd.Database.Migrations</packageId>
					<packageVersion>6.0.41</packageVersion>
					<assembly>MediaiBox.Cms.FrontEnd.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target>201512010000000_Mib_FirstMigration</target>
						<afterSQL></afterSQL>
					</down>
				</migration>
			</migrations>
		</package>
		<package>
			<id>3</id>
			<name>MediaiBoxCore</name>
			<description>Migrations related to the MediaiBox Core</description>
			<nuget>
				<name>AgileContent</name>
				<url>https://nuget.agilesvcs.com/v3/index.json</url>
				<credentials>
					<username>me</username>
					<pass>mePass</pass>
				</credentials>
			</nuget>
			<mibMigratorVersion>6.0.43</mibMigratorVersion>
			<mibDatabaseConfig>
				<type>sql2005</type>
				<server>127.0.0.1</server>
				<database>api1</database>
				<username>sa</username>
				<password>myDatabasePassword</password>
				<timeout>30</timeout>
				<port>1433</port>
			</mibDatabaseConfig>
			<migrations>
				<migration>
					<packageId>MediaiBox.Core.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.Core.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
				<migration>
					<packageId>MediaiBox.Cms.Api.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.Cms.Api.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
				<migration>
					<packageId>MediaiBox.ContentCriteria.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.ContentCriteria.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
			</migrations>
		</package>
		<package>
			<id>4</id>
			<name>Authorization</name>
			<disable>false</disable>
			<description>Auth Database Migrations</description>
			<nuget>
				<name>AgileContent</name>
				<url>https://nuget.agilesvcs.com/v3/index.json</url>
				<credentials>
					<username>me</username>
					<pass>mePass</pass>
				</credentials>
			</nuget>
			<mibMigratorVersion>6.0.43</mibMigratorVersion>
			<mibDatabaseConfig>
				<type>sql2005</type>
				<server>127.0.0.1</server>
				<database>auth1</database>
				<username>sa</username>
				<password>myDatabasePassword</password>
				<timeout>30</timeout>
				<port>1433</port>
			</mibDatabaseConfig>
			<migrations>
				<migration>
					<packageId>MediaiBox.Core.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.Core.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
				<migration>
					<packageId>MediaiBox.Cms.Authorization.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.Cms.Authorization.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
				<migration>
					<packageId>MediaiBox.Agents.Plugins.Mailer.Database.Migrations</packageId>
					<packageVersion>6.0.43</packageVersion>
					<assembly>MediaiBox.Agents.Plugins.Mailer.Database.Migrations.dll</assembly>
					<up>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</up>
					<down>
						<beforeSQL></beforeSQL>
						<target></target>
						<afterSQL></afterSQL>
					</down>
				</migration>
			</migrations>
		</package>
	</migrationPackages>
</config>