Database management

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. 

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 --version 8.0.0-*

The tool-manifest need to be created in the folder before a local tool can be installed. 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 migrate 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.

Adding admin user

When running Litium in an non windows environment you can't use the winsows credentials to login. Instead you need to create an admin user directly in the database. Use the user command from litium-db to create the admin user.

dotnet litium-db user --connection [connectionstring] --login username --password pasword

if you have the connection string in your json-config file you can directly use that to add the admin user

dotnet litium-db user --file [path to the config.json file] --login username --password password