Visit the project website for more information.
Head to uCommerce website to know more about uCommerce.
"uCommerce Migrations" allows the generation and deletion of uCommerce artifacts from code. It serves as a foundation for which migrations can be created and run using a migration runner.
For questions or feedback on uCommerce Migrations, please use uCommerce Migration discussion group.
"uCommerce Migrations for FluentMigrator" uses FluentMigrator infrastructure to run migrations that maintain uCommerce artifacts.
As of now, it is the preferred way to use uCommerce migrations
- uCommerce v4.0.2.13277 or above already installed (might work with previous versions, but it has not been verified)
- NOTE: the connection string to the database is needed to run the migrations
- NOTE: no version of uCommerce is distributed with the library, it will have to be downloaded, installed and ready to be reference from your source code.
- A .Net 4.0 framework project. The library does not use any four-specific features, so it should work in previous and higher versions of the framework.
Since the purpose of the library is help migrating uCommerce artifacts, we assume that there is already an installed supported version of uCommerce and that you know the connection string to its database.
- Create a .NET class library project in Visual Studio
- Add references to the following uCommerce-specific assemblies:
- UCommerce.dll
- UCommerce.Infrastructure.dll
- NHibernate.dll
- Install the nuget package
uCommerce_migrations_runners_FluentMigrator
Create FluentMigrator migrations that inherit from uCommerceMigration
For example:
[Migration(1)]
public class M01_DataTypeMigration : uCommerceMigration
{
protected override void MigrateUp()
{
Definition justImportedCategory = Migrator.CategoryDefinition("JustImported", "This category keep products which are just imported by integration.");
Migrator.Save(justImportedCategory);
}
protected override void MigrateDown()
{
Migrator.DeleteCategoryDefinition("JustImported");
}
}
uCommerce migrations are run using FluentMigrator runner Migrate.exe
and providing the database connection to uCommerce database but there are a number of requirements to be fulfilled.
- Several uCommerce-specific assemblies need to be accesible for
Migrate.exe
(usually copied to the same directory)- Castle.Core.dll
- Castle.Windsor.dll (in 5.x versions)
- NHibernate.dll
- FluentNHibernate.dll
- Iesi.Collections.dll
- Infralution.Licensing.dll
- UCommerce.dll
- UCommerce.Infrastructure.dll
- The following file needs to be accesible for
Migrate.exe
(usually copied to the same directory)\Infrastructure\Components.config
Yes.
Since we cannot provide uCommerce within the package, nor we wanted to take a hard dependency on it, these steps are, unfortunately, necessary.
But they do not have to be manual.
The way the process can be automatized varies from project, but it always boils down to have some sort of script that:
- copies the aforementioned artifacts needed to run the migrations
- Invoke
Migrate.exe
An example of such migration runner script can be found in Run-Samples.ps1
If, for some reason, using FluentMigrator is out of the question, the core nuget package uCommerce_migrations
can be installed separately.
This package provides the core functionality to migrate artifacts and can be invoked from anywhere.
For example, you might want to run the code to create the necessary artifacts when the uCommerce application starts. But using the migration model is recommended.