delete assets with a non-existent tenant and set default asset profile to the assets with xss
This commit is contained in:
		
							parent
							
								
									2d2d78ae6b
								
							
						
					
					
						commit
						0849aa722f
					
				@ -622,6 +622,8 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
 | 
			
		||||
                        schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.4.1", "schema_update_before.sql");
 | 
			
		||||
                        loadSql(schemaUpdateFile, conn);
 | 
			
		||||
 | 
			
		||||
                        conn.createStatement().execute("DELETE FROM asset a WHERE NOT exists(SELECT id FROM tenant WHERE id = a.tenant_id);");
 | 
			
		||||
 | 
			
		||||
                        log.info("Creating default asset profiles...");
 | 
			
		||||
                        PageLink pageLink = new PageLink(1000);
 | 
			
		||||
                        PageData<TbPair<UUID, String>> pageData;
 | 
			
		||||
@ -654,6 +656,9 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
 | 
			
		||||
                        log.info("Updating asset profiles...");
 | 
			
		||||
                        conn.createStatement().execute("call update_asset_profiles()");
 | 
			
		||||
 | 
			
		||||
                        conn.createStatement().execute("UPDATE asset a SET asset_profile_id = " +
 | 
			
		||||
                                "(SELECT id FROM asset_profile ap WHERE ap.tenant_id = a.tenant_id AND name='default') WHERE a.asset_profile_id IS NULL;");
 | 
			
		||||
 | 
			
		||||
                        schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.4.1", "schema_update_after.sql");
 | 
			
		||||
                        loadSql(schemaUpdateFile, conn);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user