Browse Source

fix(migration): user query runner for broken entities recovery to avoid type issues

Nicolas Meienberger 2 years ago
parent
commit
9c2bcc2280

+ 3 - 0
docker-compose.dev.yml

@@ -80,6 +80,9 @@ services:
 networks:
   tipi_main_network:
     driver: bridge
+    driver_opts:
+      com.docker.network.bridge.enable_ip_masquerade: "true"
+      com.docker.network.bridge.enable_icc: "true"
     ipam:
       driver: default
       config:

+ 6 - 4
packages/system-api/src/core/updates/recover-migrations.ts

@@ -6,9 +6,11 @@ import Update from '../../modules/system/update.entity';
 
 const recover = async () => {
   logger.info('Recovering broken database');
-  const apps = await App.find();
-  const users = await User.find();
-  const updated = await Update.find();
+
+  const queryRunner = datasource.createQueryRunner();
+  const apps = await queryRunner.query('SELECT * FROM app');
+  const users = await queryRunner.query('SELECT * FROM "user"');
+  const updates = await queryRunner.query('SELECT * FROM update');
 
   // drop database
   await datasource.dropDatabase();
@@ -27,7 +29,7 @@ const recover = async () => {
   }
 
   // create updates
-  for (const update of updated) {
+  for (const update of updates) {
     await Update.create(update).save();
   }