Skip to content

Commit

Permalink
adds a patch for the Sqlite migration update from the Binner file sto…
Browse files Browse the repository at this point in the history
…rage provider.

OrganizationIds were being set _before_ the data was imported, so they have to be done differently for this single provider.
  • Loading branch information
replaysMike committed Apr 23, 2023
1 parent 8610c6b commit 5936076
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Binner/Library/Binner.Common/StorageProviders/MigrationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,33 @@ private bool MigrateBinnerToSqlite(Binner.Model.Common.IBinnerDb binnerDb, int u

// create the Sqlite database
_logger.Info("Migrating Binner database to Sqlite...");

context.Database.Migrate();

// import data
ImportBinnerDb(binnerDb, context, userId);

// reapply the data migration for Sqlite, because there was no data during migrate no OrganizationIds were set as intended.
context.Database.ExecuteSql($@"
UPDATE OAuthCredentials SET OrganizationId = 1;
UPDATE OAuthRequests SET OrganizationId = 1;
UPDATE Parts SET OrganizationId = 1;
UPDATE PartSuppliers SET OrganizationId = 1;
UPDATE PartTypes SET OrganizationId = 1;
UPDATE Pcbs SET OrganizationId = 1;
UPDATE PcbStoredFileAssignments SET OrganizationId = 1;
UPDATE ProjectPartAssignments SET OrganizationId = 1;
UPDATE ProjectPcbAssignments SET OrganizationId = 1;
UPDATE Projects SET OrganizationId = 1;
UPDATE StoredFiles SET OrganizationId = 1;
UPDATE UserIntegrationConfigurations SET OrganizationId = 1;
UPDATE UserLoginHistory SET OrganizationId = 1;
UPDATE UserPrinterConfigurations SET OrganizationId = 1;
UPDATE UserPrinterTemplateConfigurations SET OrganizationId = 1;
UPDATE Users SET OrganizationId = 1;
UPDATE UserTokens SET OrganizationId = 1;
");

_logger.Info("Successfully migrated Binner database to Sqlite!");
// success!
return true;
Expand Down

0 comments on commit 5936076

Please sign in to comment.