Migrating LiteDB to PostgreSQL after Universal V5 Upgrade

Product: PowerShell Universal
Version: 4.1.1

Hello everyone,

I recently attempted to upgrade my Universal from V4 to V5, but unfortunately, the upgrade broke my setup because V5 no longer supports LiteDB.

Is there a way to migrate my existing LiteDB database to PostgreSQL? Any guidance or tools that could help with this migration would be greatly appreciated.

Thanks in advance for your help!

Based on the information you’ve shared, it seems like you’re trying to migrate from LiteDB to PostgreSQL due to version 5 no longer supporting LiteDB. To assist you better, I’d like to guide you through this process.

Migration Suggestions:

  1. Database Export: Unfortunately, PSU does not provide a direct migration tool from LiteDB to PostgreSQL, but one option is to manually export the data from LiteDB and import it into PostgreSQL. You can use LiteDB Studio to browse and export your data into JSON or CSV format.
  2. Database Configuration: Once the data is exported, you can configure PostgreSQL in your PowerShell Universal installation. To do this:
  • Stop the PSU service.
  • Update the appsettings.json file to configure the PostgreSQL connection string under the Database section.
  • Example configuration:
"Database": {
  "ConnectionString": "Host=your_host;Database=your_database;Username=your_user;Password=your_password",
  "Provider": "PostgreSql"
}
  1. Data Import: You will need to import the LiteDB-exported data into your new PostgreSQL database. Depending on the format of your exported data, you can use PostgreSQL’s import functionality to achieve this.

For detailed information on setting up PostgreSQL with PSU, refer to the following documentation: PowerShell Universal

I recommend backing up all your data before proceeding with the migration. Let me know if you run into any issues during this process, and feel free to share the logs or screenshots if necessary.

We appreciate your patience.

Best regards,
Ruben Tapia

Any reason to use Postgre vs sqllite? There is a migration tool for that

Hello,

I have an idea to migrate LiteDB to PostgreSQL, and there is a specific reason behind it: I want to centralize all our databases into a single, unified solution.

I plan to migrate LiteDB to SQLite using “psudb.exe” and then migrate SQLite to PostgreSQL using a tool called “pgloader.”

I’m currently running some tests and have set up a test environment on a virtual machine. However, I’m encountering an issue. When I install PowerShell Universal V4, the service stops automatically, and I receive the following error:

2024-10-17 10:52:08.148 +02:00 [FTL] Fatal error starting PowerShell Universal.
System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.IO.FileInfo..ctor(String originalPath, String fullPath, String fileName, Boolean isNormalized)
   at System.IO.FileInfo..ctor(String fileName)
   at UniversalAutomation.LiteDBv5Database.SetupTables() in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\LiteDBDatabase.cs:line 119
   at UniversalAutomation.LiteDBv5Database..ctor(IServiceProvider serviceProvider, String connectionString) in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\LiteDBDatabase.cs:line 88
   at UniversalAutomation.LiteDBv5.DatabaseFeature.GetDatabase(IServiceProvider serviceProvider, String connectionString) in C:\actions-runner\_work\universal\universal\src\UniversalAutomation.LiteDBv5\Plugin.cs:line 41
   at Universal.Server.Services.SystemPluginService.<>c__DisplayClass4_0.<AddDatabase>b__2(IServiceProvider x) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\SystemPluginService.cs:line 83
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Universal.Server.Program.<>c__DisplayClass4_0.<Main>b__0(Options o) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Program.cs:line 83

I’ve already tried uninstalling .NET, PowerShell Universal V4, and remove folder, but the issue persists.

Do you have any suggestions or ideas on how to resolve this?

I managed to solve this problem.

For people who have this problem, I succeeded using :

  Start-Process msiexec.exe -ArgumentList “/I C:\Users\adamr\Downloads\PowerShellUniversal.4 .2.7.msi /q /norestart /L*V `“C:\users\adamr\desktop\msi.log.txt`” STARTSERVICE=0 SERVICEACCOUNT=contoso\service_account SERVICEACCOUNTPASSWORD=ThisPasswordWillBeReplacedWithAsterisksInTheMSILogs” -Wait -NoNewWindow