From ebc9ef824219be9e27a96a74f0d8a02c4ec6ae9a Mon Sep 17 00:00:00 2001 From: Adrien Dessy Date: Mon, 22 Jul 2024 11:29:15 +0200 Subject: [PATCH 1/2] [TAN-2254] Delete extraneous copies of map configs and layers A bug in the project copy process caused map configs without mappable and their associated layers to be copied with every project, leading to an exponential increase in the number of map configs for some tenants. This migration removes all map configs without a mappable and their associated layers to bring the number of records back in check. Since map configs without mappables are meant to be transient, this should not result in data loss, though it may affect ongoing edits to surveys. --- ...955_remove_map_configs_without_mappable.rb | 22 +++++++++++++++++++ back/db/structure.sql | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 back/db/migrate/20240722090955_remove_map_configs_without_mappable.rb diff --git a/back/db/migrate/20240722090955_remove_map_configs_without_mappable.rb b/back/db/migrate/20240722090955_remove_map_configs_without_mappable.rb new file mode 100644 index 000000000000..aa5492f71d9e --- /dev/null +++ b/back/db/migrate/20240722090955_remove_map_configs_without_mappable.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# This is a data migration. It does not change the schema. +class RemoveMapConfigsWithoutMappable < ActiveRecord::Migration[7.0] + class MapConfig < ApplicationRecord + self.table_name = 'maps_map_configs' + end + + class Layer < ApplicationRecord + self.table_name = 'maps_layers' + + belongs_to :map_config, class_name: 'MapConfig' + end + + def change + map_configs = MapConfig.where(mappable_id: nil, mappable_type: nil) + layers = Layer.where(map_config: map_configs) + + layers.delete_all + map_configs.delete_all + end +end diff --git a/back/db/structure.sql b/back/db/structure.sql index 4a3645a5fd42..e38004228b52 100644 --- a/back/db/structure.sql +++ b/back/db/structure.sql @@ -7510,6 +7510,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20240516113700'), ('20240606112752'), ('20240612134240'), -('202407081751'); +('202407081751'), +('20240722090955'); From a6e83855d0a756f595e7bc74a01ec3dc00c63b31 Mon Sep 17 00:00:00 2001 From: Iva Date: Mon, 22 Jul 2024 15:45:12 +0300 Subject: [PATCH 2/2] Fix e2e test --- front/cypress/e2e/folder_page.cy.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/front/cypress/e2e/folder_page.cy.ts b/front/cypress/e2e/folder_page.cy.ts index 69674bd83484..92925cc15ca8 100644 --- a/front/cypress/e2e/folder_page.cy.ts +++ b/front/cypress/e2e/folder_page.cy.ts @@ -52,12 +52,6 @@ describe('Project selection page', () => { cy.get('#e2e-folder-page'); }); - it('shows where you are', () => { - cy.get('.e2e-projects-dropdown-link') - .should('have.class', 'active') - .should('be.visible'); - }); - it('shows the folder title', () => { cy.get('#e2e-folder-title').contains(folderTitle); });