Manage upgrades of the Litium platform database with the db tool.
To manage the upgrade of the Litium platform database the litium-db dotnet tool is used. This is a command-line tool that can migrate the database from the previous version or generate a script that can be executed later.
In the below examples the connection string is in the following format
"Pooling=true;User Id=user;Password=secret;Database=litium;Server=127.0.0.1;TrustServerCertificate=True"
Installation
The litium-db tool is automatic installed with Litium Accelerator. To manually install as a local tool use the following command:
dotnet new tool-manifest
dotnet tool install Litium.Application.Migrations --local [--version (Litium version)]
The tool-manifest need to be created in the folder before a local tool can be installed. The --version an be added to point for a specific version of the litium-db tool. We do not recommend installing the litium-db tool as a global tool because you can only have one version installed.
Upgrade a database
With the update command you can execute the database upgrade.
dotnet litium-db update --connection [connectionstring]
if you have the connection string in your json-config file you can directly use that for migration
dotnet litium-db update --file [path to the config.json file]
Generate script
With the pre-script and script command, you can create the database script that is needed for the manual upgrade of the database. For example, if the scripts should be sent to Litium Support for applying to the customer database.
dotnet litium-db pre-script -o prerequisite.sql
dotnet litium-db script -o upgrade.sql
The pre-script is used to validate the information in the database before starting the migration. If the validation script is failing with an error message the upgrade should be aborted and the database needs to be corrected regarding the instructions in the error.
|