SQL Server
Harmony has a dependency to SQL Server databases which can be installed on Windows or Linux. After installing an SQL Server instance, proceed by creating the required databases and configuring the connection strings for the following two databases:
Harmony: The core database used by the Harmony.Api server app, containing all the core tables and their relationships, e.g. Workspaces, Boards or Cards.
Harmony.Notifications.Jobs: The database used by the Harmony.Notifications web app, containing all the HangFire required tables and one more.
Harmony.Automations.Jobs: The database used by the Harmony.Automations web app, containing all the HangFire required tables and one more.
Harmony database configuration
Database connection string
Configure the HarmonyConnection SQL Server's connection string existing in the appsettings.json file at the root of the Harmony.Api project to point to your SQL Server instance.
Database migrations
You can run the database migrations either manually or let the projects run them for you during startup.
Run migrations through Visual Studio
When running migrations through Visual Studio, open the Package Manager Console
and set the Default project
to src\Infrastructure\Harmony.Persistence. This should be the default project when running other migrations as well (NotificationContext & AutomationContext examples following)
Run the following command to create the database:
Migrations command require that you have previously setup your database connection string properly.
In case you decide to create a new migration, follow the same procedure by replacing the command with the following:
Run migrations using a command line
You can run database migrations from a command line as well. First you need to have installed EF Core tools.
In case you had previously installed a dotnet-ef version other than the latest, update it by running the following command:
dotnet tool install --global dotnet-ef
Open a terminal and navigate at the root of the Harmony.Persistence project, where the HarmonyContext database context class exists.
Run the dotnet ef command to create the database
In case you have installed a local SQL Server on a Linux machine accepting a Developer license, you need to add Encrypt=False; at the end of your connection string before running migration commands, otherwise you will get an error. Also keep in mind that for Linux SQL Server installations your connection string should use username and password rather than windows authentication. Harmony has been tested successfully ✅ on Windows and an Ubuntu 22.04 machine. SQL Server for Ubuntu was installed following this guide.
Just a reminder here: It's optional to run the migrations by yourself because they will run by default at startup. At a later release, this will be active only in debug mode.
To disable the automatic migrations remove the following line from the ApplicationBuilderExtensions class.
Harmony.Notifications & Harmony.Automations jobs database configuration
Database connection string
Configure the SQL Server's HarmonyJobsConnection connection strings existing in the appsettings.json file at the root of the Harmony.Notifications & Harmony.Automations projects to point to your SQL Server instance.
Harmony.Notifications appsettings.json
Harmony.Automations appsettings.json
Database migrations
Use the same process & commands you used for Harmony database and Harmony.Api projects except that you have to change the following two parameters:
-Context: NotificationContext or AutomationContext
-StartUpProject: Harmony.Notifications or Harmony.Automations
Examples:
Read next - configure the MongoDB Server
pageMongoDB ServerLast updated