From f5429b3668dfde3e40eb29a3c83dde75c1769fe8 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 09:14:59 -0400 Subject: [PATCH 01/10] Remove old migrations --- .../20200518185559-initial-migration.js | 20 - ...20200521003201-create_table_test_issues.js | 36 -- ...-serialized-form-column-to-test-results.js | 13 - .../20200528143617-add-run-status.js | 21 - .../20200528143624-add-run-status-to-run.js | 18 - ...8172804-add-run-status-to-run-data-view.js | 100 --- ...te-browser-version-to-at-and-at-version.js | 53 -- .../20200915184800-AddActiveFlags.js | 52 -- .../20200915203422-AddColumnsToTestRun.js | 70 --- ...te-create-browser-version-to-at-version.js | 142 ----- .../20200929194042-AddActiveToTestVersions.js | 30 - .../20201016203157-RemoveTestCycleModel.js | 132 ---- ...01232332-add-links-columns-apg-examples.js | 35 -- .../20210512004505-BuildNewDatabaseSchema.js | 98 --- .../20210524210332-TestQueueChanges.js | 223 ------- ...0601152335-supportNewTestQueueMutations.js | 97 --- .../20210601152340-emptyObsoleteTables.js | 16 - ...-removeTestPlanTargetVersionConstraints.js | 70 --- .../migrations/20210809220722-UserSettings.js | 14 - .../20210920195544-reportingBackend.js | 36 -- .../20211116172219-commandSequences.js | 89 --- .../20211118143508-testRowNumber.js | 63 -- .../20220427145338-alterAtVersionTable.js | 40 -- ...220427192638-changeConstraintsAtVersion.js | 22 - ...20220427194229-addIdConstraintAtVersion.js | 22 - .../20220427204420-changeAtVersionColumn.js | 19 - ...20220503193406-alterBrowserVersionTable.js | 56 -- .../20220509140537-removeTestPlanTarget.js | 126 ---- ...20220712044433-changeJsonbArraysToJsonb.js | 86 --- ...220801210224-updateJawsTestInstructions.js | 83 --- ...0825125643-addStatusChangeUpdateColumns.js | 66 -- ...20919142951-addVendorReviewStatusColumn.js | 32 - .../20220928162616-addViewersToTests.js | 38 -- .../20220929155024-addMetricsColumn.js | 26 - .../20220929155029-addMetricsValues.js | 97 --- ...1116154332-updateTestPlanReportStatuses.js | 26 - ...-removeInReviewStatusFromTestPlanReport.js | 9 - .../migrations/20230424152008-addAtBrowser.js | 29 - .../20230424152008-createTestPlanTable.js | 38 -- .../20230425152008-createTestPlanColumns.js | 60 -- ...30425215656-updateTestPlanVersionTitles.js | 29 - ...30501220810-deduplicateTestPlanVersions.js | 593 ------------------ .../20230523163855-addColumnsToAtBrowsers.js | 39 -- ...3856-remove-OtherUnexpectedBehaviorText.js | 167 ----- ...8170853-addDateColumnsToTestPlanVersion.js | 113 ---- ...ameCandidateStatusReachedAtToApprovedAt.js | 62 -- ...PhaseReachedAtColumnsForTestPlanVersion.js | 80 --- ...230719174358-removeTestPlanReportStatus.js | 27 - .../20230823212533-addCollectionJobs.js | 37 -- ...gDeprecatedAtAndReorderPhaseChangeDates.js | 159 ----- .../20230927172432-addVersionStrings.js | 85 --- ...dd-initiatedByAutomation-to-testPlanRun.js | 15 - .../20231031162340-verifyNoSkippedTests.js | 63 -- ...15-addScreenTextAndInstructionsToAtMode.js | 34 - ...sultsUnexpectedBehaviorImpactAndDetails.js | 59 -- .../20231219212344-recalculateV2TestHashes.js | 14 - ...deAdditionalTestFormatVersionAttributes.js | 67 -- ...25130-includeMissingAssertionExceptions.js | 42 -- ...teMetricsForCountingUnexpectedBehaviors.js | 61 -- ...3914-includeAssertionIdInTestAssertions.js | 45 -- ...0240229195433-modifyCollectionJobIdType.js | 87 --- .../migrations/20240305205951-removeAtMode.js | 39 -- ...92910-removeRequiredAndOptionalPriority.js | 72 --- ...20240312122457-testPlanReportAtVersions.js | 70 --- ...20240312131258-browserVersionReleasedAt.js | 26 - ...6-updateMetricsForUsingTotalCalculation.js | 61 -- ...3145124-addIsPrimaryColumnToTestPlanRun.js | 27 - ...190618-updateCandidatePhaseReachedDates.js | 53 -- ...182449-addKeyColumnToAtAndBrowserTables.js | 36 -- ...51-cleanupDuplicatesAndRegenerateHashes.js | 133 ---- ...1203810-fixCommandButtonPhaseChangeDate.js | 61 -- ...240404171101-addCollectionJobTestStatus.js | 58 -- server/migrations/20240509102300-addIsBot.js | 23 - .../20240516195950-updateMetrics.js | 61 -- ...0522032230-fixIncorrectDeprecationDates.js | 113 ---- .../20240525041559-addCollectionJobSecret.js | 27 - .../20240711160607-update-may-terminology.js | 54 -- ...15150459-resetTestPlanVersionIdToLatest.js | 32 - .../20240724212706-updateMetrics.js | 64 -- 79 files changed, 5191 deletions(-) delete mode 100644 server/migrations/20200518185559-initial-migration.js delete mode 100644 server/migrations/20200521003201-create_table_test_issues.js delete mode 100644 server/migrations/20200522002555-add-serialized-form-column-to-test-results.js delete mode 100644 server/migrations/20200528143617-add-run-status.js delete mode 100644 server/migrations/20200528143624-add-run-status-to-run.js delete mode 100644 server/migrations/20200528172804-add-run-status-to-run-data-view.js delete mode 100644 server/migrations/20200915181019-create-browser-version-to-at-and-at-version.js delete mode 100644 server/migrations/20200915184800-AddActiveFlags.js delete mode 100644 server/migrations/20200915203422-AddColumnsToTestRun.js delete mode 100644 server/migrations/20200928035513-update-create-browser-version-to-at-version.js delete mode 100644 server/migrations/20200929194042-AddActiveToTestVersions.js delete mode 100644 server/migrations/20201016203157-RemoveTestCycleModel.js delete mode 100644 server/migrations/20201201232332-add-links-columns-apg-examples.js delete mode 100644 server/migrations/20210512004505-BuildNewDatabaseSchema.js delete mode 100644 server/migrations/20210524210332-TestQueueChanges.js delete mode 100644 server/migrations/20210601152335-supportNewTestQueueMutations.js delete mode 100644 server/migrations/20210601152340-emptyObsoleteTables.js delete mode 100644 server/migrations/20210601152341-removeTestPlanTargetVersionConstraints.js delete mode 100644 server/migrations/20210809220722-UserSettings.js delete mode 100644 server/migrations/20210920195544-reportingBackend.js delete mode 100644 server/migrations/20211116172219-commandSequences.js delete mode 100644 server/migrations/20211118143508-testRowNumber.js delete mode 100644 server/migrations/20220427145338-alterAtVersionTable.js delete mode 100644 server/migrations/20220427192638-changeConstraintsAtVersion.js delete mode 100644 server/migrations/20220427194229-addIdConstraintAtVersion.js delete mode 100644 server/migrations/20220427204420-changeAtVersionColumn.js delete mode 100644 server/migrations/20220503193406-alterBrowserVersionTable.js delete mode 100644 server/migrations/20220509140537-removeTestPlanTarget.js delete mode 100644 server/migrations/20220712044433-changeJsonbArraysToJsonb.js delete mode 100644 server/migrations/20220801210224-updateJawsTestInstructions.js delete mode 100644 server/migrations/20220825125643-addStatusChangeUpdateColumns.js delete mode 100644 server/migrations/20220919142951-addVendorReviewStatusColumn.js delete mode 100644 server/migrations/20220928162616-addViewersToTests.js delete mode 100644 server/migrations/20220929155024-addMetricsColumn.js delete mode 100644 server/migrations/20220929155029-addMetricsValues.js delete mode 100644 server/migrations/20221116154332-updateTestPlanReportStatuses.js delete mode 100644 server/migrations/20230329214527-removeInReviewStatusFromTestPlanReport.js delete mode 100644 server/migrations/20230424152008-addAtBrowser.js delete mode 100644 server/migrations/20230424152008-createTestPlanTable.js delete mode 100644 server/migrations/20230425152008-createTestPlanColumns.js delete mode 100644 server/migrations/20230425215656-updateTestPlanVersionTitles.js delete mode 100644 server/migrations/20230501220810-deduplicateTestPlanVersions.js delete mode 100644 server/migrations/20230523163855-addColumnsToAtBrowsers.js delete mode 100644 server/migrations/20230523163856-remove-OtherUnexpectedBehaviorText.js delete mode 100644 server/migrations/20230608170853-addDateColumnsToTestPlanVersion.js delete mode 100644 server/migrations/20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js delete mode 100644 server/migrations/20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js delete mode 100644 server/migrations/20230719174358-removeTestPlanReportStatus.js delete mode 100644 server/migrations/20230823212533-addCollectionJobs.js delete mode 100644 server/migrations/20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js delete mode 100644 server/migrations/20230927172432-addVersionStrings.js delete mode 100644 server/migrations/20230927230957-add-initiatedByAutomation-to-testPlanRun.js delete mode 100644 server/migrations/20231031162340-verifyNoSkippedTests.js delete mode 100644 server/migrations/20231114170315-addScreenTextAndInstructionsToAtMode.js delete mode 100644 server/migrations/20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js delete mode 100644 server/migrations/20231219212344-recalculateV2TestHashes.js delete mode 100644 server/migrations/20240104150500-includeAdditionalTestFormatVersionAttributes.js delete mode 100644 server/migrations/20240111225130-includeMissingAssertionExceptions.js delete mode 100644 server/migrations/20240215220201-updateMetricsForCountingUnexpectedBehaviors.js delete mode 100644 server/migrations/20240224173914-includeAssertionIdInTestAssertions.js delete mode 100644 server/migrations/20240229195433-modifyCollectionJobIdType.js delete mode 100644 server/migrations/20240305205951-removeAtMode.js delete mode 100644 server/migrations/20240311192910-removeRequiredAndOptionalPriority.js delete mode 100644 server/migrations/20240312122457-testPlanReportAtVersions.js delete mode 100644 server/migrations/20240312131258-browserVersionReleasedAt.js delete mode 100644 server/migrations/20240312145416-updateMetricsForUsingTotalCalculation.js delete mode 100644 server/migrations/20240313145124-addIsPrimaryColumnToTestPlanRun.js delete mode 100644 server/migrations/20240319190618-updateCandidatePhaseReachedDates.js delete mode 100644 server/migrations/20240321182449-addKeyColumnToAtAndBrowserTables.js delete mode 100644 server/migrations/20240325205951-cleanupDuplicatesAndRegenerateHashes.js delete mode 100644 server/migrations/20240401203810-fixCommandButtonPhaseChangeDate.js delete mode 100644 server/migrations/20240404171101-addCollectionJobTestStatus.js delete mode 100644 server/migrations/20240509102300-addIsBot.js delete mode 100644 server/migrations/20240516195950-updateMetrics.js delete mode 100644 server/migrations/20240522032230-fixIncorrectDeprecationDates.js delete mode 100644 server/migrations/20240525041559-addCollectionJobSecret.js delete mode 100644 server/migrations/20240711160607-update-may-terminology.js delete mode 100644 server/migrations/20240715150459-resetTestPlanVersionIdToLatest.js delete mode 100644 server/migrations/20240724212706-updateMetrics.js diff --git a/server/migrations/20200518185559-initial-migration.js b/server/migrations/20200518185559-initial-migration.js deleted file mode 100644 index 421fb8248..000000000 --- a/server/migrations/20200518185559-initial-migration.js +++ /dev/null @@ -1,20 +0,0 @@ -const fs = require('fs'); - -module.exports = { - up: queryInterface => { - return Promise.resolve() - .then(function () { - return fs.readFileSync( - __dirname + '/pg_dump_from_flyway_migrations.dump', - 'utf-8' - ); - }) - .then(function (initialSchema) { - return queryInterface.sequelize.query(initialSchema); - }); - }, - - down: queryInterface => { - return queryInterface.dropAllTables(); - } -}; diff --git a/server/migrations/20200521003201-create_table_test_issues.js b/server/migrations/20200521003201-create_table_test_issues.js deleted file mode 100644 index 55c63a165..000000000 --- a/server/migrations/20200521003201-create_table_test_issues.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('test_issue', { - id: { - type: Sequelize.INTEGER, - primaryKey: true, - autoIncrement: true - }, - test_id: { - type: Sequelize.INTEGER, - allowNull: false, - references: { - model: 'test', - key: 'id' - } - }, - run_id: { - type: Sequelize.INTEGER, - allowNull: false, - references: { - model: 'run', - key: 'id' - } - }, - issue_number: { - type: Sequelize.INTEGER, - allowNull: false - } - }); - }, - down: queryInterface => { - return queryInterface.dropTable('test_issue'); - } -}; diff --git a/server/migrations/20200522002555-add-serialized-form-column-to-test-results.js b/server/migrations/20200522002555-add-serialized-form-column-to-test-results.js deleted file mode 100644 index 4079824d5..000000000 --- a/server/migrations/20200522002555-add-serialized-form-column-to-test-results.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.addColumn('test_result', 'serialized_form', { - type: Sequelize.JSONB - }); - }, - - down: queryInterface => { - return queryInterface.removeColumn('test_result', 'serialized_form'); - } -}; diff --git a/server/migrations/20200528143617-add-run-status.js b/server/migrations/20200528143617-add-run-status.js deleted file mode 100644 index 67ac31424..000000000 --- a/server/migrations/20200528143617-add-run-status.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('run_status', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true - }, - name: { - type: Sequelize.TEXT, - allowNull: false - } - }); - }, - down: queryInterface => { - return queryInterface.dropTable('run_status'); - } -}; diff --git a/server/migrations/20200528143624-add-run-status-to-run.js b/server/migrations/20200528143624-add-run-status-to-run.js deleted file mode 100644 index 64e71a886..000000000 --- a/server/migrations/20200528143624-add-run-status-to-run.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.addColumn('run', 'run_status_id', { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'run_status', - key: 'id' - } - }); - }, - - down: queryInterface => { - return queryInterface.removeColumn('run', 'run_status_id'); - } -}; diff --git a/server/migrations/20200528172804-add-run-status-to-run-data-view.js b/server/migrations/20200528172804-add-run-status-to-run-data-view.js deleted file mode 100644 index be8e63adb..000000000 --- a/server/migrations/20200528172804-add-run-status-to-run-data-view.js +++ /dev/null @@ -1,100 +0,0 @@ -'use strict'; - -let updateViewQuery = ` -CREATE OR REPLACE VIEW run_data AS -SELECT - r.id AS id, - r.test_cycle_id AS test_cycle_id, - browser_version.version AS browser_version, - browser.name AS browser_name, - browser.id AS browser_id, - at.key AS at_key, - at.id AS at_id, - at_name.name AS at_name, - at_name.id AS at_name_id, - at_version.version AS at_version, - apg_example.directory AS apg_example_directory, - apg_example.name AS apg_example_name, - apg_example.id AS apg_example_id, - r.run_status_id AS run_status_id, - r.run_status AS run_status -FROM - ( - SELECT - run.id as id, - run.test_cycle_id as test_cycle_id, - run.browser_version_id, - run.at_id, - run.at_version_id, - run.apg_example_id, - run_status.name as run_status, - run_status.id as run_status_id - FROM - run - LEFT JOIN run_status ON run_status.id = run.run_status_id - ) as r, - browser_version, - browser, - at, - at_name, - at_version, - apg_example -WHERE - r.browser_version_id = browser_version.id - AND browser_version.browser_id = browser.id - AND r.at_id = at.id - AND at.at_name_id = at_name.id - AND r.at_version_id = at_version.id - AND r.apg_example_id = apg_example.id -; -`; -let originalViewQuery = ` -CREATE OR REPLACE VIEW run_data AS -SELECT - run.id AS id, - run.test_cycle_id AS test_cycle_id, - browser_version.version AS browser_version, - browser.name AS browser_name, - browser.id AS browser_id, - at.key AS at_key, - at.id AS at_id, - at_name.name AS at_name, - at_name.id AS at_name_id, - at_version.version AS at_version, - apg_example.directory AS apg_example_directory, - apg_example.name AS apg_example_name, - apg_example.id AS apg_example_id -FROM - run, - browser_version, - browser, - at, - at_name, - at_version, - apg_example -WHERE - run.browser_version_id = browser_version.id - AND browser_version.browser_id = browser.id - AND run.at_id = at.id - AND at.at_name_id = at_name.id - AND run.at_version_id = at_version.id - AND run.apg_example_id = apg_example.id -; -`; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.query(updateViewQuery); - }, - async down(queryInterface) { - const transaction = await queryInterface.sequelize.transaction(); - try { - await queryInterface.sequelize.query(`DROP VIEW IF EXISTS run_data`); - await queryInterface.sequelize.query(originalViewQuery); - await transaction.commit(); - } catch (err) { - await transaction.rollback(); - throw err; - } - } -}; diff --git a/server/migrations/20200915181019-create-browser-version-to-at-and-at-version.js b/server/migrations/20200915181019-create-browser-version-to-at-and-at-version.js deleted file mode 100644 index 932a24a0b..000000000 --- a/server/migrations/20200915181019-create-browser-version-to-at-and-at-version.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('BrowserVersionToAtAndAtVersions', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - browser_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'browser_version', - key: 'id' - }, - allowNull: false - }, - at_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'at_version', - key: 'id' - }, - allowNull: false - }, - at_id: { - type: Sequelize.INTEGER, - references: { - model: 'at', - key: 'id' - }, - allowNull: false - }, - active: { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: queryInterface => { - return queryInterface.dropTable('BrowserVersionToAtAndAtVersions'); - } -}; diff --git a/server/migrations/20200915184800-AddActiveFlags.js b/server/migrations/20200915184800-AddActiveFlags.js deleted file mode 100644 index 419e4c957..000000000 --- a/server/migrations/20200915184800-AddActiveFlags.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn( - 'apg_example', - 'active', - { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - { transaction: t } - ), - queryInterface.addColumn( - 'at', - 'active', - { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'active', - { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - { transaction: t } - ) - ]); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.removeColumn('apg_example', 'active', { - transaction: t - }), - queryInterface.removeColumn('at', 'active', { transaction: t }), - queryInterface.removeColumn('run', 'active', { transaction: t }) - ]); - }); - } -}; diff --git a/server/migrations/20200915203422-AddColumnsToTestRun.js b/server/migrations/20200915203422-AddColumnsToTestRun.js deleted file mode 100644 index 700cdbb68..000000000 --- a/server/migrations/20200915203422-AddColumnsToTestRun.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn( - 'run', - 'browser_version_to_at_and_at_versions_id', - { - type: Sequelize.INTEGER, - references: { - model: 'BrowserVersionToAtAndAtVersions', - key: 'id' - } - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'test_version_id', - { - type: Sequelize.INTEGER - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'created_at', - { - type: Sequelize.DATE, - defaultValue: Sequelize.NOW - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'updated_at', - { - type: Sequelize.DATE, - defaultValue: Sequelize.NOW - }, - { transaction: t } - ) - ]); - }); - }, - down: queryInterface => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.removeColumn( - 'run', - 'browser_version_to_at_and_at_versions_id', - { - transaction: t - } - ), - queryInterface.removeColumn('run', 'test_version_id', { - transaction: t - }), - queryInterface.removeColumn('run', 'created_at', { - transaction: t - }), - queryInterface.removeColumn('run', 'updated_at', { - transaction: t - }) - ]); - }); - } -}; diff --git a/server/migrations/20200928035513-update-create-browser-version-to-at-version.js b/server/migrations/20200928035513-update-create-browser-version-to-at-version.js deleted file mode 100644 index 9ff2c6aee..000000000 --- a/server/migrations/20200928035513-update-create-browser-version-to-at-version.js +++ /dev/null @@ -1,142 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async t => { - await queryInterface.removeColumn( - 'run', - 'browser_version_to_at_and_at_versions_id', - { transaction: t } - ); - await queryInterface.dropTable('BrowserVersionToAtAndAtVersions', { - transaction: t - }); - await queryInterface.createTable( - 'browser_version_to_at_version', - { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - browser_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'browser_version', - key: 'id' - }, - allowNull: false - }, - at_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'at_version', - key: 'id' - }, - allowNull: false - }, - active: { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }, - { transaction: t } - ); - return queryInterface.addColumn( - 'run', - 'browser_version_to_at_versions_id', - { - type: Sequelize.INTEGER, - references: { - model: 'browser_version_to_at_version', - key: 'id' - } - }, - { transaction: t } - ); - }); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async t => { - await queryInterface.removeColumn( - 'run', - 'browser_version_to_at_versions_id', - { transaction: t } - ); - await queryInterface.dropTable('browser_version_to_at_version', { - transaction: t - }); - await queryInterface.createTable( - 'BrowserVersionToAtAndAtVersions', - { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - browser_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'browser_version', - key: 'id' - }, - allowNull: false - }, - at_version_id: { - type: Sequelize.INTEGER, - references: { - model: 'at_version', - key: 'id' - }, - allowNull: false - }, - at_id: { - type: Sequelize.INTEGER, - references: { - model: 'at', - key: 'id' - }, - allowNull: false - }, - active: { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }, - { transaction: t } - ); - return queryInterface.addColumn( - 'run', - 'browser_version_to_at_and_at_versions_id', - { - type: Sequelize.INTEGER, - references: { - model: 'BrowserVersionToAtAndAtVersions', - key: 'id' - } - }, - { transaction: t } - ); - }); - } -}; diff --git a/server/migrations/20200929194042-AddActiveToTestVersions.js b/server/migrations/20200929194042-AddActiveToTestVersions.js deleted file mode 100644 index dc7d71fac..000000000 --- a/server/migrations/20200929194042-AddActiveToTestVersions.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn( - 'test_version', - 'active', - { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - }, - { transaction: t } - ) - ]); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.removeColumn('test_version', 'active', { - transaction: t - }) - ]); - }); - } -}; diff --git a/server/migrations/20201016203157-RemoveTestCycleModel.js b/server/migrations/20201016203157-RemoveTestCycleModel.js deleted file mode 100644 index 88c58ac52..000000000 --- a/server/migrations/20201016203157-RemoveTestCycleModel.js +++ /dev/null @@ -1,132 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.dropTable('test_cycle', { - cascade: true, - transaction: t - }), - queryInterface.sequelize.query('DROP VIEW run_data', { - transaction: t - }), - queryInterface.removeColumn('run', 'test_cycle_id', { - transaction: t - }), - queryInterface.removeColumn('run', 'at_version_id', { - transaction: t - }), - queryInterface.removeColumn('run', 'at_id', { - transaction: t - }), - queryInterface.removeColumn('run', 'browser_version_id', { - transaction: t - }) - ]); - }); - }, - - down: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn( - 'run', - 'test_cycle_id', - { - type: Sequelize.INTEGER - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'at_version_id', - { - type: Sequelize.INTEGER - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'at_id', - { - type: Sequelize.INTEGER - }, - { transaction: t } - ), - queryInterface.addColumn( - 'run', - 'browser_version_id', - { - type: Sequelize.INTEGER - }, - { transaction: t } - ), - queryInterface.createTable( - 'test_cycle', - { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true - }, - name: { - type: Sequelize.TEXT, - allowNull: true - }, - test_version_id: { - type: Sequelize.INTEGER, - allowNull: false, - references: { - model: 'test_version', - key: 'id' - } - }, - created_user_id: { - type: Sequelize.INTEGER, - allowNull: false, - references: { - model: 'users', - key: 'id' - } - }, - date: { - type: Sequelize.DATEONLY, - allowNull: true - } - }, - { transaction: t } - ), - - queryInterface.sequelize.query( - ` - CREATE VIEW public.run_data AS - SELECT run.id, - run.test_cycle_id, - browser_version.version AS browser_version, - browser.name AS browser_name, - browser.id AS browser_id, - at.key AS at_key, - at.id AS at_id, - at_name.name AS at_name, - at_name.id AS at_name_id, - at_version.version AS at_version, - apg_example.directory AS apg_example_directory, - apg_example.name AS apg_example_name, - apg_example.id AS apg_example_id - FROM public.run, - public.browser_version, - public.browser, - public.at, - public.at_name, - public.at_version, - public.apg_example - WHERE ((run.browser_version_id = browser_version.id) AND (browser_version.browser_id = browser.id) AND (run.at_id = at.id) AND (at.at_name_id = at_name.id) AND (run.at_version_id = at_version.id) AND (run.apg_example_id = apg_example.id)); - `, - { transaction: t } - ) - ]); - }); - } -}; diff --git a/server/migrations/20201201232332-add-links-columns-apg-examples.js b/server/migrations/20201201232332-add-links-columns-apg-examples.js deleted file mode 100644 index 5d640d795..000000000 --- a/server/migrations/20201201232332-add-links-columns-apg-examples.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn( - 'apg_example', - 'example', - { type: Sequelize.TEXT }, - { transaction: t } - ), - queryInterface.addColumn( - 'apg_example', - 'design_pattern', - { type: Sequelize.TEXT }, - { transaction: t } - ) - ]); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.removeColumn('apg_example', 'example', { - transaction: t - }), - queryInterface.removeColumn('apg_example', 'design_pattern', { - transaction: t - }) - ]); - }); - } -}; diff --git a/server/migrations/20210512004505-BuildNewDatabaseSchema.js b/server/migrations/20210512004505-BuildNewDatabaseSchema.js deleted file mode 100644 index 90170caec..000000000 --- a/server/migrations/20210512004505-BuildNewDatabaseSchema.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -const fs = require('fs'); - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(transaction => { - return Promise.all([ - queryInterface.dropTable('at_name', { - cascade: true, - transaction - }), - queryInterface.dropTable('browser', { - cascade: true, - transaction - }), - queryInterface.dropTable('at_version', { - cascade: true, - transaction - }), - queryInterface.dropTable('browser_version', { - cascade: true, - transaction - }), - queryInterface.dropTable('test_version', { - cascade: true, - transaction - }), - queryInterface.dropTable('run_status', { - cascade: true, - transaction - }), - queryInterface.dropTable('browser_version_to_at_version', { - cascade: true, - transaction - }), - queryInterface.dropTable('apg_example', { - cascade: true, - transaction - }), - queryInterface.dropTable('at', { cascade: true, transaction }), - queryInterface.dropTable('role', { - cascade: true, - transaction - }), - queryInterface.dropTable('users', { - cascade: true, - transaction - }), - queryInterface.dropTable('test_status', { - cascade: true, - transaction - }), - queryInterface.dropTable('run', { cascade: true, transaction }), - queryInterface.dropTable('test', { - cascade: true, - transaction - }), - queryInterface.dropTable('user_to_role', { - cascade: true, - transaction - }), - queryInterface.dropTable('user_to_at', { - cascade: true, - transaction - }), - queryInterface.dropTable('tester_to_run', { - cascade: true, - transaction - }), - queryInterface.dropTable('test_result', { - cascade: true, - transaction - }), - queryInterface.dropTable('test_issue', { - cascade: true, - transaction - }), - queryInterface.dropTable('test_to_at', { - cascade: true, - transaction - }), - Promise.resolve() - .then(() => - fs.readFileSync( - __dirname + '/pg_dump_2021_05_new_schema.sql', - 'utf-8' - ) - ) - .then(initialSchema => queryInterface.sequelize.query(initialSchema)) - ]); - }); - }, - - down: queryInterface => { - return queryInterface.dropAllTables(); - } -}; diff --git a/server/migrations/20210524210332-TestQueueChanges.js b/server/migrations/20210524210332-TestQueueChanges.js deleted file mode 100644 index 5df5a0b56..000000000 --- a/server/migrations/20210524210332-TestQueueChanges.js +++ /dev/null @@ -1,223 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameTable('TestPlan', 'TestPlanVersion', { - transaction - }); - - await queryInterface.renameColumn( - 'TestPlanVersion', - 'publishStatus', - 'status', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanVersion', - 'sourceGitCommitHash', - 'gitSha', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanVersion', - 'sourceGitCommitMessage', - 'gitMessage', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanVersion', - 'createdAt', - 'updatedAt', - { transaction } - ); - await queryInterface.removeColumn('TestPlanVersion', 'parsed', { - transaction - }); - await queryInterface.addColumn( - 'TestPlanVersion', - 'tests', - Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.JSONB), - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanVersion', - 'metadata', - Sequelize.DataTypes.JSONB, - { transaction } - ); - - await queryInterface.renameColumn( - 'TestPlanReport', - 'publishStatus', - 'status', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanReport', - 'testPlan', - 'testPlanVersionId', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanReport', - 'testPlanTarget', - 'testPlanTargetId', - { transaction } - ); - await queryInterface.removeColumn('TestPlanReport', 'coveragePercent', { - transaction - }); - - await queryInterface.renameColumn( - 'TestPlanRun', - 'tester', - 'testerUserId', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanRun', - 'testPlanReport', - 'testPlanReportId', - { transaction } - ); - await queryInterface.removeColumn('TestPlanRun', 'isManuallyTested', { - transaction - }); - await queryInterface.addColumn( - 'TestPlanRun', - 'testResults', - Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.JSONB), - { transaction } - ); - - await queryInterface.renameColumn('AtMode', 'at', 'atId', { - transaction - }); - await queryInterface.renameColumn('AtVersion', 'at', 'atId', { - transaction - }); - await queryInterface.renameColumn( - 'BrowserVersion', - 'browser', - 'browserId', - { transaction } - ); - - await queryInterface.dropTable('TestResult', { transaction }); - }); - }, - - down: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameTable('TestPlanVersion', 'TestPlan', { - transaction - }); - - await queryInterface.renameColumn('TestPlan', 'status', 'publishStatus', { - transaction - }); - await queryInterface.renameColumn( - 'TestPlan', - 'gitSha', - 'sourceGitCommitHash', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlan', - 'gitMessage', - 'sourceGitCommitMessage', - { transaction } - ); - await queryInterface.renameColumn('TestPlan', 'updatedAt', 'createdAt', { - transaction - }); - await queryInterface.removeColumn('TestPlan', 'tests', { - transaction - }); - await queryInterface.addColumn( - 'TestPlan', - 'parsed', - Sequelize.DataTypes.JSONB, - { transaction } - ); - await queryInterface.removeColumn('TestPlan', 'metadata', { - transaction - }); - - await queryInterface.renameColumn( - 'TestPlanReport', - 'status', - 'publishStatus', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanReport', - 'testPlanVersionId', - 'testPlan', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanReport', - 'testPlanTargetId', - 'testPlanTarget', - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanReport', - 'coveragePercent', - Sequelize.DataTypes.NUMERIC, - { transaction } - ); - - await queryInterface.renameColumn( - 'TestPlanRun', - 'testerUserId', - 'tester', - { transaction } - ); - await queryInterface.renameColumn( - 'TestPlanRun', - 'testPlanReportId', - 'testPlanReport', - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanRun', - 'isManuallyTested', - Sequelize.DataTypes.BOOLEAN, - { transaction } - ); - await queryInterface.removeColumn('TestPlanRun', 'testResults', { - transaction - }); - - await queryInterface.renameColumn('AtMode', 'atId', 'at', { - transaction - }); - await queryInterface.renameColumn('AtVersion', 'atId', 'at', { - transaction - }); - await queryInterface.renameColumn( - 'BrowserVersion', - 'browserId', - 'browser', - { transaction } - ); - - queryInterface.createTable('TestResult', { - startedAt: { - type: Sequelize.DataTypes.DATE, - defaultValue: Sequelize.DataTypes.NOW - }, - completedAt: { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - testPlanRun: { type: Sequelize.DataTypes.INTEGER }, - data: { type: Sequelize.DataTypes.JSONB } - }); - }); - } -}; diff --git a/server/migrations/20210601152335-supportNewTestQueueMutations.js b/server/migrations/20210601152335-supportNewTestQueueMutations.js deleted file mode 100644 index ba206be5b..000000000 --- a/server/migrations/20210601152335-supportNewTestQueueMutations.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface /* , Sequelize */) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn('TestPlanTarget', 'at', 'atId', { - transaction - }); - await queryInterface.renameColumn( - 'TestPlanTarget', - 'browser', - 'browserId', - { transaction } - ); - await queryInterface.renameColumn( - 'BrowserVersion', - 'version', - 'browserVersion', - { transaction } - ); - await queryInterface.renameColumn('AtVersion', 'version', 'atVersion', { - transaction - }); - await queryInterface.bulkUpdate( - 'Role', - { name: 'ADMIN' }, - { name: 'admin' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'Role', - { name: 'TESTER' }, - { name: 'tester' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'UserRoles', - { roleName: 'ADMIN' }, - { roleName: 'admin' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'UserRoles', - { roleName: 'TESTER' }, - { roleName: 'tester' }, - { transaction } - ); - }); - }, - - down: (queryInterface /* , Sequelize */) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn('TestPlanTarget', 'atId', 'at', { - transaction - }); - await queryInterface.renameColumn( - 'TestPlanTarget', - 'browserId', - 'browser', - { transaction } - ); - await queryInterface.renameColumn( - 'BrowserVersion', - 'browserVersion', - 'version', - { transaction } - ); - await queryInterface.renameColumn('AtVersion', 'atVersion', 'version', { - transaction - }); - await queryInterface.bulkUpdate( - 'Role', - { name: 'admin' }, - { name: 'ADMIN' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'Role', - { name: 'tester' }, - { name: 'TESTER' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'UserRoles', - { roleName: 'admin' }, - { roleName: 'ADMIN' }, - { transaction } - ); - await queryInterface.bulkUpdate( - 'UserRoles', - { roleName: 'tester' }, - { roleName: 'TESTER' }, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20210601152340-emptyObsoleteTables.js b/server/migrations/20210601152340-emptyObsoleteTables.js deleted file mode 100644 index b711d4103..000000000 --- a/server/migrations/20210601152340-emptyObsoleteTables.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.bulkDelete('TestPlanRun', {}, { transaction }); - await queryInterface.bulkDelete('TestPlanReport', {}, { transaction }); - await queryInterface.bulkDelete('TestPlanTarget', {}, { transaction }); - await queryInterface.bulkDelete('TestPlanVersion', {}, { transaction }); - await queryInterface.bulkDelete('AtVersion', {}, { transaction }); - await queryInterface.bulkDelete('BrowserVersion', {}, { transaction }); - }); - }, - - down: () => {} -}; diff --git a/server/migrations/20210601152341-removeTestPlanTargetVersionConstraints.js b/server/migrations/20210601152341-removeTestPlanTargetVersionConstraints.js deleted file mode 100644 index e72f78ca3..000000000 --- a/server/migrations/20210601152341-removeTestPlanTargetVersionConstraints.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.changeColumn( - 'TestPlanTarget', - 'atVersion', - { - type: Sequelize.DataTypes.TEXT - }, - { transaction } - ); - - await queryInterface.changeColumn( - 'TestPlanTarget', - 'browserVersion', - { - type: Sequelize.DataTypes.TEXT - }, - { transaction } - ); - - await queryInterface.changeColumn( - 'AtVersion', - 'atVersion', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - primaryKey: true - }, - { transaction } - ); - await queryInterface.changeColumn( - 'BrowserVersion', - 'browserVersion', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - primaryKey: true - }, - { transaction } - ); - - await queryInterface.removeConstraint( - 'TestPlanTarget', - 'TestPlanTarget_atVersion_fkey', - { transaction } - ); - await queryInterface.removeConstraint( - 'TestPlanTarget', - 'TestPlanTarget_browserVersion_fkey', - { transaction } - ); - - await queryInterface.removeConstraint( - 'AtVersion', - 'AtVersion_version_key', - { transaction } - ); - await queryInterface.removeConstraint( - 'BrowserVersion', - 'BrowserVersion_version_key', - { transaction } - ); - }); - }, - - down: () => {} -}; diff --git a/server/migrations/20210809220722-UserSettings.js b/server/migrations/20210809220722-UserSettings.js deleted file mode 100644 index ff3c6ead3..000000000 --- a/server/migrations/20210809220722-UserSettings.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('UserAts', { - userId: { type: Sequelize.DataTypes.INTEGER }, - atId: { type: Sequelize.DataTypes.INTEGER } - }); - }, - - down: async (queryInterface /* , Sequelize */) => { - await queryInterface.dropTable('UserAts'); - } -}; diff --git a/server/migrations/20210920195544-reportingBackend.js b/server/migrations/20210920195544-reportingBackend.js deleted file mode 100644 index c50b7ee02..000000000 --- a/server/migrations/20210920195544-reportingBackend.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanVersion', - 'directory', - Sequelize.DataTypes.TEXT, - { transaction } - ); - await queryInterface.removeColumn('TestPlanVersion', 'status', { - transaction - }); - await queryInterface.renameColumn( - 'TestPlanVersion', - 'exampleUrl', - 'testPageUrl', - { transaction } - ); - // Delete existing data! - const options = { - transaction, - truncate: true, - restartIdentity: true, - cascade: true - }; - await queryInterface.bulkDelete('AtVersion', {}, options); - await queryInterface.bulkDelete('BrowserVersion', {}, options); - await queryInterface.bulkDelete('TestPlanRun', {}, options); - await queryInterface.bulkDelete('TestPlanTarget', {}, options); - await queryInterface.bulkDelete('TestPlanVersion', {}, options); - await queryInterface.bulkDelete('TestPlanReport', {}, options); - }); - } -}; diff --git a/server/migrations/20211116172219-commandSequences.js b/server/migrations/20211116172219-commandSequences.js deleted file mode 100644 index e0e9c00c0..000000000 --- a/server/migrations/20211116172219-commandSequences.js +++ /dev/null @@ -1,89 +0,0 @@ -const { omit } = require('lodash'); -const { TestPlanVersion } = require('../models'); -const commandList = require('../resources/commandsV1.json'); - -module.exports = { - up: async queryInterface => { - const [[{ count: testPlanVersionCount }]] = - await queryInterface.sequelize.query( - `SELECT COUNT(*) FROM "TestPlanVersion"` - ); - if (!Number(testPlanVersionCount)) return; - - const testPlanVersions = await TestPlanVersion.findAll({ - attributes: { - exclude: [ - 'testPlanId', - 'phase', - 'candidatePhaseReachedAt', - 'recommendedPhaseReachedAt', - 'recommendedPhaseTargetDate' - ] - } - }); - await Promise.all( - testPlanVersions.map(testPlanVersion => { - const newTests = testPlanVersion.tests.map(test => ({ - ...test, - scenarios: test.scenarios.map(scenario => ({ - ...omit(scenario, ['commandId']), - commandIds: (() => { - // This special case only applies to the sandbox - // due to a previous version of this migration. - if (scenario.commandIds) { - if (scenario.commandIds[0].includes(',')) { - return scenario.commandIds[0].split(','); - } - return scenario.commandIds; - } - if (scenario.commandId.includes(',')) { - return scenario.commandId.split(','); - } - return [scenario.commandId]; - })() - })), - renderableContent: Object.fromEntries( - Object.entries(test.renderableContent).map(([atId, content]) => [ - atId, - { - ...content, - // prettier-ignore - commands: content.commands.map(command => { - const keypresses = (() => { - if (command.id.includes(',')) { - const ids = command.id - .split(',') - .map(id => id.replace(/"/g, '')); // remove quotes - return ids.map(id => ({ - id, - keystroke: commandList - .find(each => each.id === id) - ?.text || (() => { - throw new Error( - `Command '${id}' found which is not in commands.json` - ); - })() - })); - } - const { id, keystroke } = command; - return [{ id, keystroke }]; - })(); - - return { - ...command, - keystroke: keypresses - .map(({ keystroke }) => keystroke) - .join(', then '), - keypresses - }; - }) - } - ]) - ) - })); - testPlanVersion.tests = newTests; - return testPlanVersion.save(); - }) - ); - } -}; diff --git a/server/migrations/20211118143508-testRowNumber.js b/server/migrations/20211118143508-testRowNumber.js deleted file mode 100644 index 2f56d002f..000000000 --- a/server/migrations/20211118143508-testRowNumber.js +++ /dev/null @@ -1,63 +0,0 @@ -const { omit } = require('lodash'); -const { TestPlanVersion } = require('../models'); - -module.exports = { - up: async queryInterface => { - const [[{ count: testPlanVersionCount }]] = - await queryInterface.sequelize.query( - `SELECT COUNT(*) FROM "TestPlanVersion"` - ); - if (!Number(testPlanVersionCount)) return; - - const testPlanVersions = await TestPlanVersion.findAll({ - attributes: { - exclude: [ - 'testPlanId', - 'phase', - 'candidatePhaseReachedAt', - 'recommendedPhaseReachedAt', - 'recommendedPhaseTargetDate' - ] - } - }); - await Promise.all( - testPlanVersions.map(testPlanVersion => { - const newTests = testPlanVersion.tests.map((test, index) => { - const number = index + 1; - const anyAtId = test.atIds[0]; - const { testId } = test.renderableContent[anyAtId].info; - if (testId !== number) throw new Error('Unexpected'); - return { - ...test, - rowNumber: testId - }; - }); - testPlanVersion.tests = newTests; - return testPlanVersion.save(); - }) - ); - }, - - down: async () => { - const testPlanVersions = await TestPlanVersion.findAll({ - attributes: { - exclude: [ - 'testPlanId', - 'phase', - 'candidatePhaseReachedAt', - 'recommendedPhaseReachedAt', - 'recommendedPhaseTargetDate' - ] - } - }); - await Promise.all( - testPlanVersions.map(testPlanVersion => { - const newTests = testPlanVersion.tests.map(test => { - return omit(test, ['rowNumber']); - }); - testPlanVersion.tests = newTests; - return testPlanVersion.save(); - }) - ); - } -}; diff --git a/server/migrations/20220427145338-alterAtVersionTable.js b/server/migrations/20220427145338-alterAtVersionTable.js deleted file mode 100644 index 65bbc2034..000000000 --- a/server/migrations/20220427145338-alterAtVersionTable.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'AtVersion', - 'id', - { - type: Sequelize.DataTypes.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true - }, - { transaction } - ); - await queryInterface.addColumn( - 'AtVersion', - 'releasedAt', - { - type: Sequelize.DataTypes.DATE, - allowNull: false, - defaultValue: new Date() - }, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('AtVersion', 'id', { - transaction - }); - await queryInterface.removeColumn('AtVersion', 'releasedAt', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20220427192638-changeConstraintsAtVersion.js b/server/migrations/20220427192638-changeConstraintsAtVersion.js deleted file mode 100644 index f3211041e..000000000 --- a/server/migrations/20220427192638-changeConstraintsAtVersion.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeConstraint('AtVersion', 'AtVersion_pkey', { - transaction - }); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addConstraint('AtVersion', { - type: 'primary key', - name: 'AtVersion_pkey', - fields: ['atId', 'atVersion'], - transaction - }); - }); - } -}; diff --git a/server/migrations/20220427194229-addIdConstraintAtVersion.js b/server/migrations/20220427194229-addIdConstraintAtVersion.js deleted file mode 100644 index 18e8b210d..000000000 --- a/server/migrations/20220427194229-addIdConstraintAtVersion.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addConstraint('AtVersion', { - type: 'primary key', - name: 'AtVersion_pkey', - fields: ['id'], - transaction - }); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeConstraint('AtVersion', 'AtVersion_pkey', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20220427204420-changeAtVersionColumn.js b/server/migrations/20220427204420-changeAtVersionColumn.js deleted file mode 100644 index 1423dd974..000000000 --- a/server/migrations/20220427204420-changeAtVersionColumn.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn('AtVersion', 'atVersion', 'name', { - transaction - }); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn('AtVersion', 'name', 'atVersion', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20220503193406-alterBrowserVersionTable.js b/server/migrations/20220503193406-alterBrowserVersionTable.js deleted file mode 100644 index 6fba81e33..000000000 --- a/server/migrations/20220503193406-alterBrowserVersionTable.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'BrowserVersion', - 'id', - { - type: Sequelize.DataTypes.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true - }, - { transaction } - ); - await queryInterface.removeConstraint( - 'BrowserVersion', - 'BrowserVersion_pkey', - { transaction } - ); - await queryInterface.addConstraint('BrowserVersion', { - type: 'primary key', - name: 'BrowserVersion_pkey', - fields: ['id'], - transaction - }); - await queryInterface.renameColumn( - 'BrowserVersion', - 'browserVersion', - 'name', - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('BrowserVersion', 'id', { - transaction - }); - await queryInterface.renameColumn( - 'BrowserVersion', - 'name', - 'browserVersion', - { transaction } - ); - await queryInterface.addConstraint('BrowserVersion', { - type: 'primary key', - name: 'BrowserVersion_pkey', - fields: ['browserId', 'browserVersion'], - transaction - }); - }); - } -}; diff --git a/server/migrations/20220509140537-removeTestPlanTarget.js b/server/migrations/20220509140537-removeTestPlanTarget.js deleted file mode 100644 index a44986518..000000000 --- a/server/migrations/20220509140537-removeTestPlanTarget.js +++ /dev/null @@ -1,126 +0,0 @@ -const util = require('util'); -const exec = util.promisify(require('child_process').exec); -const fs = require('fs'); - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'atId', - { - type: Sequelize.DataTypes.INTEGER - }, - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanReport', - 'browserId', - { - type: Sequelize.DataTypes.INTEGER - }, - { transaction } - ); - - // Populate reports with the atId and browserId which used to be in the - // TestPlanTarget table. - await queryInterface.sequelize.query( - ` - UPDATE "TestPlanReport" as tpr - SET - "atId" = tpt."atId", - "browserId" = tpt."browserId" - FROM "TestPlanTarget" AS tpt - WHERE tpr."testPlanTargetId" = tpt.id - `, - { transaction } - ); - - try { - await exec( - `pg_dump -t '"TestPlanTarget"' ${process.env.PGDATABASE} > ${__dirname}/pg_dump_test_plan_target.sql` - ); - } catch (err) { - console.error(err); - } - - await queryInterface.dropTable('TestPlanTarget', { - cascade: true, - transaction - }); - - const testPlanTargetIds = await queryInterface.sequelize.query( - `SELECT id, "testPlanTargetId" FROM "TestPlanReport"`, - { - transaction - } - ); - - const testPlanTargetIdData = testPlanTargetIds[0]; - testPlanTargetIdData.unshift('id,testPlanTargetId\n'); - const csvString = testPlanTargetIdData.reduce( - (prev, current) => `${prev}${current.id},${current.testPlanTargetId}\n` - ); - fs.writeFile(`${__dirname}/test_plan_target_id.csv`, csvString, err => { - if (err) { - console.error(err); - } - }); - - await queryInterface.removeColumn('TestPlanReport', 'testPlanTargetId', { - transaction - }); - }); - }, - - down: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanReport', 'atId', { - transaction - }); - await queryInterface.removeColumn('TestPlanReport', 'browserId', { - transaction - }); - - await queryInterface.addColumn( - 'TestPlanReport', - 'testPlanTargetId', - { - type: Sequelize.DataTypes.INTEGER - }, - { transaction } - ); - - try { - const data = fs.readFileSync( - `${__dirname}/test_plan_target_id.csv`, - 'utf-8' - ); - data.split('\n').forEach(async (value, i) => { - if (i === 0 || value === '') { - return; - } - const [id, testPlanTargetId] = value.split(','); - await queryInterface.sequelize.query( - `UPDATE "TestPlanReport" - SET "testPlanTargetId" = ${testPlanTargetId} - where id = ${id};`, - { - transaction - } - ); - }); - } catch (err) { - console.error(err); - } - - try { - await exec( - `psql ${process.env.PGDATABASE} < ${__dirname}/pg_dump_test_plan_target.sql` - ); - } catch (err) { - console.error(err); - } - }); - } -}; diff --git a/server/migrations/20220712044433-changeJsonbArraysToJsonb.js b/server/migrations/20220712044433-changeJsonbArraysToJsonb.js deleted file mode 100644 index eecf24d53..000000000 --- a/server/migrations/20220712044433-changeJsonbArraysToJsonb.js +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - // https://stackoverflow.com/a/45231776 - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanVersion" ALTER COLUMN "tests" DROP DEFAULT;`, - { transaction } - ); - await queryInterface.changeColumn( - 'TestPlanVersion', - 'tests', - { - type: 'JSONB USING to_jsonb(tests)' - }, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanVersion" ALTER COLUMN "tests" SET DEFAULT '[]';`, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanRun" ALTER COLUMN "testResults" DROP DEFAULT;`, - { transaction } - ); - await queryInterface.changeColumn( - 'TestPlanRun', - 'testResults', - { - type: 'JSONB USING to_jsonb("testResults")' - }, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanRun" ALTER COLUMN "testResults" SET DEFAULT '[]';`, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `CREATE OR REPLACE FUNCTION jsonb_to_jsonb_array(jsonb) - returns jsonb[] language sql as $$ - select array_agg(elem) - from jsonb_array_elements($1) as elem - $$;`, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanVersion" ALTER COLUMN "tests" DROP DEFAULT;`, - { transaction } - ); - await queryInterface.changeColumn( - 'TestPlanVersion', - 'tests', - { - type: 'JSONB[] USING jsonb_to_jsonb_array(tests)' - }, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanVersion" ALTER COLUMN "tests" SET DEFAULT '{}';`, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanRun" ALTER COLUMN "testResults" DROP DEFAULT;`, - { transaction } - ); - await queryInterface.changeColumn( - 'TestPlanRun', - 'testResults', - { - type: 'JSONB[] USING jsonb_to_jsonb_array("testResults")' - }, - { transaction } - ); - await queryInterface.sequelize.query( - `ALTER TABLE "TestPlanRun" ALTER COLUMN "testResults" SET DEFAULT '{}';`, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20220801210224-updateJawsTestInstructions.js b/server/migrations/20220801210224-updateJawsTestInstructions.js deleted file mode 100644 index 33d5af529..000000000 --- a/server/migrations/20220801210224-updateJawsTestInstructions.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set tests = update_data.updated_tests - from (select id, - jsonb_agg( - jsonb_build_object( - 'id', elements -> 'id', - 'atIds', elements -> 'atIds', - 'title', elements -> 'title', - 'atMode', elements -> 'atMode', - 'rowNumber', elements -> 'rowNumber', - 'scenarios', elements -> 'scenarios', - 'assertions', elements -> 'assertions', - 'renderedUrls', elements -> 'renderedUrls', - 'renderableContent', jsonb_strip_nulls( - jsonb_build_object( - '1', jsonb_set( - (elements -> 'renderableContent' -> '1')::jsonb, '{instructions, mode}', - case - when elements -> 'renderableContent' -> '1' -> 'instructions' ->> 'mode' = - 'Verify the Virtual Cursor is active by pressing Alt+Delete. If it is not, turn on the Virtual Cursor by pressing Insert+Z.' - then '"Verify the Virtual Cursor is active by pressing Alt+Delete. If it is not, exit Forms Mode to activate the Virtual Cursor by pressing Escape."'::jsonb - else (elements -> 'renderableContent' -> '1' -> 'instructions' -> 'mode')::jsonb - end), - '2', (elements -> 'renderableContent' -> '2')::jsonb, - '3', (elements -> 'renderableContent' -> '3')::jsonb) - ) - ) - ) as updated_tests - from "TestPlanVersion", - jsonb_array_elements("TestPlanVersion".tests) as elements - group by id) update_data - where update_data.id = "TestPlanVersion".id;`, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set tests = update_data.updated_tests - from (select id, - jsonb_agg( - jsonb_build_object( - 'id', elements -> 'id', - 'atIds', elements -> 'atIds', - 'title', elements -> 'title', - 'atMode', elements -> 'atMode', - 'rowNumber', elements -> 'rowNumber', - 'scenarios', elements -> 'scenarios', - 'assertions', elements -> 'assertions', - 'renderedUrls', elements -> 'renderedUrls', - 'renderableContent', jsonb_strip_nulls( - jsonb_build_object( - '1', jsonb_set( - (elements -> 'renderableContent' -> '1')::jsonb, '{instructions, mode}', - case - when elements -> 'renderableContent' -> '1' -> 'instructions' ->> 'mode' = - 'Verify the Virtual Cursor is active by pressing Alt+Delete. If it is not, exit Forms Mode to activate the Virtual Cursor by pressing Escape.' - then '"Verify the Virtual Cursor is active by pressing Alt+Delete. If it is not, turn on the Virtual Cursor by pressing Insert+Z."'::jsonb - else (elements -> 'renderableContent' -> '1' -> 'instructions' -> 'mode')::jsonb - end), - '2', (elements -> 'renderableContent' -> '2')::jsonb, - '3', (elements -> 'renderableContent' -> '3')::jsonb) - ) - ) - ) as updated_tests - from "TestPlanVersion", - jsonb_array_elements("TestPlanVersion".tests) as elements - group by id) update_data - where update_data.id = "TestPlanVersion".id;`, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20220825125643-addStatusChangeUpdateColumns.js b/server/migrations/20220825125643-addStatusChangeUpdateColumns.js deleted file mode 100644 index a2dc6c9cd..000000000 --- a/server/migrations/20220825125643-addStatusChangeUpdateColumns.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'candidateStatusReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanReport', - 'recommendedStatusReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - await queryInterface.addColumn( - 'TestPlanReport', - 'recommendedStatusTargetDate', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - await queryInterface.sequelize.query( - ` - update "TestPlanReport" set "candidateStatusReachedAt" = current_date where status = 'IN_REVIEW'; - update "TestPlanReport" set "recommendedStatusReachedAt" = current_date where status = 'FINALIZED'; - update "TestPlanReport" set "candidateStatusReachedAt" = current_date - 180 where status = 'FINALIZED'; - `, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn( - 'TestPlanReport', - 'candidateStatusReachedAt', - { transaction } - ); - await queryInterface.removeColumn( - 'TestPlanReport', - 'recommendedStatusReachedAt', - { transaction } - ); - await queryInterface.removeColumn( - 'TestPlanReport', - 'recommendedStatusTargetDate', - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20220919142951-addVendorReviewStatusColumn.js b/server/migrations/20220919142951-addVendorReviewStatusColumn.js deleted file mode 100644 index 1f4b4de96..000000000 --- a/server/migrations/20220919142951-addVendorReviewStatusColumn.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'vendorReviewStatus', - { - type: Sequelize.DataTypes.TEXT, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - await queryInterface.sequelize.query( - `update "TestPlanReport" set "vendorReviewStatus" = 'READY' where status = 'FINALIZED';`, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn( - 'TestPlanReport', - 'vendorReviewStatus', - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20220928162616-addViewersToTests.js b/server/migrations/20220928162616-addViewersToTests.js deleted file mode 100644 index a0045aeaf..000000000 --- a/server/migrations/20220928162616-addViewersToTests.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set tests = update_data.updated_tests - from (select id, - jsonb_agg( - jsonb_set(elements, '{viewers}', '[]'::jsonb) - ) as updated_tests - from "TestPlanVersion", - jsonb_array_elements("TestPlanVersion".tests) as elements - group by id) update_data - where update_data.id = "TestPlanVersion".id;`, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set tests = update_data.updated_tests - from (select id, - jsonb_agg(elements - 'viewers' - ) as updated_tests - from "TestPlanVersion", - jsonb_array_elements("TestPlanVersion".tests) as elements - group by id) update_data - where update_data.id = "TestPlanVersion".id;`, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20220929155024-addMetricsColumn.js b/server/migrations/20220929155024-addMetricsColumn.js deleted file mode 100644 index 5464fea35..000000000 --- a/server/migrations/20220929155024-addMetricsColumn.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'metrics', - { - type: Sequelize.DataTypes.JSONB, - defaultValue: {}, - allowNull: false - }, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanReport', 'metrics', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20220929155029-addMetricsValues.js b/server/migrations/20220929155029-addMetricsValues.js deleted file mode 100644 index e62dec22d..000000000 --- a/server/migrations/20220929155029-addMetricsValues.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -const populateData = require('../services/PopulatedData/populateData'); -const conflictsResolver = require('../resolvers/TestPlanReport/conflictsResolver'); -const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); -const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); -const { getMetrics } = require('shared'); -const { - updateTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const getGraphQLContext = require('../graphql-context'); - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanReports = await queryInterface.sequelize.query( - `SELECT id, status FROM "TestPlanReport"`, - { - transaction - } - ); - const testPlanReportsData = testPlanReports[0]; - - for (let i = 0; i < testPlanReportsData.length; i++) { - const testPlanReportId = testPlanReportsData[i].id; - const status = testPlanReportsData[i].status; - - // eslint-disable-next-line no-console - console.info( - `=== Calculating metrics for TestPlanReport:${testPlanReportId} ===` - ); - let updateParams = {}; - - const { testPlanReport } = await populateData( - { testPlanReportId }, - { context } - ); - - const conflicts = await conflictsResolver( - testPlanReport, - null, - context - ); - updateParams = { - metrics: { - conflictsCount: conflicts.length - } - }; - - if (status === 'IN_REVIEW' || status === 'FINALIZED') { - const finalizedTestResults = - finalizedTestResultsResolver( - { ...testPlanReport, status }, - null, - context - ) || []; - if (finalizedTestResults.length) { - const runnableTests = runnableTestsResolver( - testPlanReport, - null, - context - ); - const metrics = getMetrics({ - testPlanReport: { - ...testPlanReport, - finalizedTestResults, - runnableTests - } - }); - updateParams = { - metrics: { ...updateParams.metrics, ...metrics } - }; - } - } - - await updateTestPlanReportById({ - id: testPlanReport.id, - values: updateParams, - transaction - }); - } - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanReport" set "metrics" = '{}'`, - { - transaction - } - ); - }); - } -}; diff --git a/server/migrations/20221116154332-updateTestPlanReportStatuses.js b/server/migrations/20221116154332-updateTestPlanReportStatuses.js deleted file mode 100644 index fce33bb38..000000000 --- a/server/migrations/20221116154332-updateTestPlanReportStatuses.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanReport" set status = 'CANDIDATE' where status = 'FINALIZED'`, - { - transaction - } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanReport" set status = 'FINALIZED' where status = 'CANDIDATE'; - update "TestPlanReport" set status = 'FINALIZED' where status = 'RECOMMENDED'`, - { - transaction - } - ); - }); - } -}; diff --git a/server/migrations/20230329214527-removeInReviewStatusFromTestPlanReport.js b/server/migrations/20230329214527-removeInReviewStatusFromTestPlanReport.js deleted file mode 100644 index 10572962b..000000000 --- a/server/migrations/20230329214527-removeInReviewStatusFromTestPlanReport.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = { - up: async queryInterface => { - await queryInterface.sequelize.query( - `update "TestPlanReport" set status = 'DRAFT' where status = 'IN_REVIEW'` - ); - } -}; diff --git a/server/migrations/20230424152008-addAtBrowser.js b/server/migrations/20230424152008-addAtBrowser.js deleted file mode 100644 index 72c2273ee..000000000 --- a/server/migrations/20230424152008-addAtBrowser.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('AtBrowsers', { - atId: { - type: Sequelize.DataTypes.INTEGER, - allowNull: false, - references: { - model: 'At', - key: 'id' - } - }, - browserId: { - type: Sequelize.DataTypes.INTEGER, - allowNull: false, - references: { - model: 'Browser', - key: 'id' - } - } - }); - }, - - down: async (queryInterface /* , Sequelize */) => { - await queryInterface.dropTable('AtBrowsers'); - } -}; diff --git a/server/migrations/20230424152008-createTestPlanTable.js b/server/migrations/20230424152008-createTestPlanTable.js deleted file mode 100644 index 71ed3c86d..000000000 --- a/server/migrations/20230424152008-createTestPlanTable.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - const t = await queryInterface.sequelize.transaction(); - - try { - await queryInterface.createTable( - 'TestPlan', - { - id: { - type: Sequelize.DataTypes.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true - }, - title: Sequelize.DataTypes.TEXT, - directory: Sequelize.DataTypes.TEXT - }, - { transaction: t } - ); - await t.commit(); - } catch (error) { - await t.rollback(); - } - }, - - async down(queryInterface) { - const t = await queryInterface.sequelize.transaction(); - try { - await queryInterface.dropTable('TestPlan', { transaction: t }); - await t.commit(); - } catch (error) { - await t.rollback(); - } - } -}; diff --git a/server/migrations/20230425152008-createTestPlanColumns.js b/server/migrations/20230425152008-createTestPlanColumns.js deleted file mode 100644 index 6526f99b5..000000000 --- a/server/migrations/20230425152008-createTestPlanColumns.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - const t = await queryInterface.sequelize.transaction(); - try { - await queryInterface.addColumn( - 'TestPlanVersion', - 'testPlanId', - { - type: Sequelize.DataTypes.INTEGER, - references: { - model: { - tableName: 'TestPlan' - }, - key: 'id' - } - }, - { transaction: t } - ); - - await queryInterface.addColumn( - 'TestPlanReport', - 'testPlanId', - { - type: Sequelize.DataTypes.INTEGER, - references: { - model: { - tableName: 'TestPlan' - }, - key: 'id' - } - }, - { transaction: t } - ); - - await t.commit(); - } catch (error) { - await t.rollback(); - } - }, - - async down(queryInterface) { - const t = await queryInterface.sequelize.transaction(); - try { - await queryInterface.dropTable('TestPlan', { transaction: t }); - await queryInterface.removeColumn('TestPlanVersion', 'testPlanId', { - transaction: t - }); - await queryInterface.removeColumn('TestPlanReport', 'testPlanId', { - transaction: t - }); - - await t.commit(); - } catch (error) { - await t.rollback(); - } - } -}; diff --git a/server/migrations/20230425215656-updateTestPlanVersionTitles.js b/server/migrations/20230425215656-updateTestPlanVersionTitles.js deleted file mode 100644 index cf38df499..000000000 --- a/server/migrations/20230425215656-updateTestPlanVersionTitles.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" set title = 'Checkbox Example (Mixed-State)' where title = 'Checkbox Example (Tri State)'`, - { - transaction - } - ); - - await queryInterface.sequelize.query( - `update "TestPlanVersion" set title = 'Alert Example' where title is null and directory = 'alert'`, - { - transaction - } - ); - - await queryInterface.sequelize.query( - `update "TestPlanVersion" set title = 'Modal Dialog Example' where title is null and directory = 'modal-dialog'`, - { - transaction - } - ); - }); - } -}; diff --git a/server/migrations/20230501220810-deduplicateTestPlanVersions.js b/server/migrations/20230501220810-deduplicateTestPlanVersions.js deleted file mode 100644 index 63dbcd870..000000000 --- a/server/migrations/20230501220810-deduplicateTestPlanVersions.js +++ /dev/null @@ -1,593 +0,0 @@ -'use strict'; - -const fetch = require('node-fetch'); -const { - createTestResultId, - createScenarioResultId, - createAssertionResultId -} = require('../services/PopulatedData/locationOfDataId'); -const { hashTest, hashTests } = require('../util/aria'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - /** - * Compute TestPlanVersion.hashedTests and return the unique TestPlanVersions found for each - * hash - * @param transaction - The Sequelize.Transaction object. - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise<{testPlanVersionsByHashedTests: {}}>} - */ - const computeTestPlanVersionHashedTests = async transaction => { - const results = await queryInterface.sequelize.query( - `SELECT COUNT(*) FROM "TestPlanVersion"`, - { transaction } - ); - const [[{ count: testPlanVersionCount }]] = results; - - const testPlanVersionBatchSize = 10; - const iterationsNeeded = Math.ceil( - testPlanVersionCount / testPlanVersionBatchSize - ); - - let testPlanVersionsByHashedTests = {}; - - for (let i = 0; i < iterationsNeeded; i += 1) { - const multipleOf100 = i % testPlanVersionBatchSize === 0; - if (multipleOf100) - // eslint-disable-next-line no-console - console.info( - 'Indexing TestPlanVersions', - i * testPlanVersionBatchSize, - 'of', - Number(testPlanVersionCount) - ); - const currentOffset = i * testPlanVersionBatchSize; - - const [testPlanVersions] = await queryInterface.sequelize.query( - `SELECT id, directory, "gitSha", tests, "updatedAt" FROM "TestPlanVersion" ORDER BY id LIMIT ? OFFSET ?`, - { - replacements: [testPlanVersionBatchSize, currentOffset], - transaction - } - ); - - await Promise.all( - testPlanVersions.map(async testPlanVersion => { - const hashedTests = hashTests(testPlanVersion.tests); - - if (!testPlanVersionsByHashedTests[hashedTests]) { - testPlanVersionsByHashedTests[hashedTests] = []; - } - testPlanVersionsByHashedTests[hashedTests].push({ - id: testPlanVersion.id, - gitSha: testPlanVersion.gitSha, - directory: testPlanVersion.directory, - updatedAt: testPlanVersion.updatedAt - }); - - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET "hashedTests" = ? WHERE id = ?`, - { - replacements: [hashedTests, testPlanVersion.id], - transaction - } - ); - }) - ); - } - - if (Number(testPlanVersionCount)) { - // eslint-disable-next-line no-console - console.info( - 'Indexed', - Number(testPlanVersionCount), - 'of', - Number(testPlanVersionCount) - ); - } - - return { testPlanVersionsByHashedTests }; - }; - - /** - * Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults, for - * TestRuns that will end up referencing tests from removed TestPlanVersions - * @param {int[]} equivalentTestPlanVersionIds - A collection of TestPlanVersion ids that - * have equivalent hashes for their tests - * @param transaction - The Sequelize.Transaction object. - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise} - */ - const regenerateExistingTestResults = async ( - equivalentTestPlanVersionIds, - transaction - ) => { - for (const key in equivalentTestPlanVersionIds) { - const [keptId, ...unkeptIds] = equivalentTestPlanVersionIds[key]; - - if (!unkeptIds.length) continue; - - // Iterate through all the TestPlanReports using unkept TestPlanVersion ids - // and update the TestRun.testResults information from the TestPlanVersion - // keptId - const unkeptTestPlanReports = await queryInterface.sequelize.query( - `SELECT id, "testPlanVersionId" FROM "TestPlanReport" WHERE "testPlanVersionId" IN (?)`, - { - replacements: [unkeptIds], - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - const keptTestPlanVersion = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion" WHERE id = ?`, - { - replacements: [keptId], - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - const { tests: keptTestPlanVersionTests } = keptTestPlanVersion[0]; - - // Iterate over all the TestPlanRuns using unkeptIds to update their - // testResults ids - for (const key in unkeptTestPlanReports) { - const { id: testPlanReportId } = unkeptTestPlanReports[key]; - - const testPlanRuns = await queryInterface.sequelize.query( - `SELECT testPlanRun.id, "testPlanReportId", "atId", "testPlanVersionId", "testResults", tests - FROM "TestPlanRun" testPlanRun - JOIN "TestPlanReport" testPlanReport ON testPlanReport.id = testPlanRun."testPlanReportId" - JOIN "TestPlanVersion" testPlanVersion ON testPlanVersion.id = testPlanReport."testPlanVersionId" - WHERE "testPlanReportId" = ?`, - { - replacements: [testPlanReportId], - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const key in testPlanRuns) { - const { - id: testPlanRunId, - atId, - testResults, - tests: unkeptTests - } = testPlanRuns[key]; - - unkeptTests.forEach(unkeptTest => { - const unkeptTestId = unkeptTest.id; - const testHash = hashTest(unkeptTest); - const foundKeptTest = keptTestPlanVersionTests.find( - keptTest => hashTest(keptTest) === testHash - ); - - testResults.forEach(testResult => { - if (testResult.testId === unkeptTestId) { - // Reassign the ids the testResult should be using - testResult.testId = foundKeptTest.id; - - // Update testResult.id - const testResultId = createTestResultId( - testPlanRunId, - testResult.testId - ); - testResult.id = testResultId; - - // The hash confirms the sub-arrays should be in the same order - testResult.scenarioResults.forEach( - (eachScenarioResult, scenarioIndex) => { - eachScenarioResult.scenarioId = - foundKeptTest.scenarios.filter( - scenario => scenario.atId === atId - )[scenarioIndex].id; - - // Update eachScenarioResult.id - const scenarioResultId = createScenarioResultId( - testResultId, - eachScenarioResult.scenarioId - ); - eachScenarioResult.id = scenarioResultId; - - eachScenarioResult.assertionResults.forEach( - (eachAssertionResult, assertionIndex) => { - eachAssertionResult.assertionId = - foundKeptTest.assertions[assertionIndex].id; - - // Update eachAssertionResult.id - eachAssertionResult.id = createAssertionResultId( - scenarioResultId, - eachAssertionResult.assertionId - ); - } - ); - } - ); - } - }); - }); - - await queryInterface.sequelize.query( - `UPDATE "TestPlanRun" SET "testResults" = ? WHERE id = ?`, - { - replacements: [JSON.stringify(testResults), testPlanRunId], - transaction - } - ); - // eslint-disable-next-line no-console - console.info('Fixing testResults for TestPlanRun', testPlanRunId); - } - } - } - }; - - /** - * Remove duplicate versions of found TestPlanVersions - * @param {int[]} equivalentTestPlanVersionIds - A collection of TestPlanVersion ids that - * have equivalent hashes for their tests - * @param transaction - The Sequelize.Transaction object. - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise} - */ - const removeTestPlanVersionDuplicates = async ( - equivalentTestPlanVersionIds, - transaction - ) => { - await Promise.all( - equivalentTestPlanVersionIds.map(async ([keptId, ...unkeptIds]) => { - if (!unkeptIds.length) return; - await queryInterface.sequelize.query( - `UPDATE "TestPlanReport" SET "testPlanVersionId" = ? WHERE "testPlanVersionId" IN (?)`, - { - replacements: [keptId, unkeptIds], - transaction - } - ); - }) - ); - - const duplicateIds = equivalentTestPlanVersionIds - .map(ids => ids.slice(1)) - .flat(); - - if (duplicateIds.length) - await queryInterface.sequelize.query( - `DELETE FROM "TestPlanVersion" WHERE id IN (?)`, - { - replacements: [duplicateIds], - transaction - } - ); - }; - - /** - * Returns an object using test directories as the key, which holds an array containing data - * on the known commits. - * Example: - * { - * alert: [ { sha: 'string', commitDate: 'dateString' }, { sha: ..., commitDate: ... }, ... ], - * banner: [ { sha: 'string', commitDate: 'dateString' }, ... ], - * ... - * } - * @returns {Promise<{}>} - */ - const getKnownGitCommits = async () => { - const testDirectories = [ - 'alert', - 'banner', - 'breadcrumb', - 'checkbox', - 'checkbox-tri-state', - 'combobox-autocomplete-both-updated', - 'combobox-select-only', - 'command-button', - 'complementary', - 'contentinfo', - 'datepicker-spin-button', - 'disclosure-faq', - 'disclosure-navigation', - 'form', - 'horizontal-slider', - 'link-css', - 'link-img-alt', - 'link-span-text', - 'main', - 'menu-button-actions', - 'menu-button-actions-active-descendant', - 'menu-button-navigation', - 'menubar-editor', - 'meter', - 'minimal-data-grid', - 'modal-dialog', - 'radiogroup-aria-activedescendant', - 'radiogroup-roving-tabindex', - 'rating-slider', - 'seek-slider', - 'slider-multithumb', - 'switch', - 'tabs-manual-activation', - 'toggle-button', - 'vertical-temperature-slider' - ]; - const knownGitCommits = {}; - - const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env; - - for (const testDirectory of testDirectories) { - if (!knownGitCommits[testDirectory]) - knownGitCommits[testDirectory] = []; - - try { - const url = `https://api.github.com/repos/w3c/aria-at/commits?path=tests/${testDirectory}`; - const authorizationHeader = `Basic ${Buffer.from( - `${GITHUB_CLIENT_ID}:${GITHUB_CLIENT_SECRET}` - ).toString('base64')}`; - const options = { - headers: { - Authorization: authorizationHeader - } - }; - - const response = await fetch(url, options); - const data = await response.json(); - - for (const commitData of data) { - if (commitData.commit?.author) { - knownGitCommits[testDirectory].push({ - sha: commitData.sha, - commitDate: commitData.commit.author.date - }); - } - } - - // eslint-disable-next-line no-console - console.info( - `Processed GitHub API commits history for tests/${testDirectory}` - ); - } catch (error) { - console.error('get.commits.error', testDirectory, error.message); - } - } - - return knownGitCommits; - }; - - /** - * Determines the TestPlanVersions which can be kept or removed. - * @param testPlanVersionsByHashedTests - TestPlanVersions separated by hashedTests - * @param knownGitCommits - Ideally, the result of {@link getKnownGitCommits} - * @returns {{testPlanVersionIdsByHashedTests: {}, testPlanVersionIdsByHashedTestsToKeep: {}, testPlanVersionIdsByHashedTestsToDelete: {}}} - */ - const processTestPlanVersionIdsByHashedTests = ( - testPlanVersionsByHashedTests, - knownGitCommits - ) => { - for (const directory in knownGitCommits) { - const gitCommits = knownGitCommits[directory]; - - // Get the testPlanVersions filtered by the directory to compare against the git - // commits data - const filteredTestPlanVersionsByHashedTestsForDirectory = - Object.fromEntries( - Object.entries(testPlanVersionsByHashedTests).filter( - // eslint-disable-next-line no-unused-vars - ([key, arr]) => arr.some(obj => obj.directory === directory) - ) - ); - - // Sort the array for each hash object so the latest date is preferred when - // assigning the isPriority flag - for (const hash in filteredTestPlanVersionsByHashedTestsForDirectory) { - filteredTestPlanVersionsByHashedTestsForDirectory[hash].sort( - (a, b) => { - const dateA = new Date(a.updatedAt); - const dateB = new Date(b.updatedAt); - return dateB - dateA; - } - ); - } - - for (const gitCommit of gitCommits) { - const { sha } = gitCommit; - for (const hash in filteredTestPlanVersionsByHashedTestsForDirectory) { - for (const testPlanVersion of filteredTestPlanVersionsByHashedTestsForDirectory[ - hash - ]) { - // Check if the found commit is the same git sha - if (sha === testPlanVersion.gitSha) { - if ( - !testPlanVersionsByHashedTests[hash].some( - obj => obj.isPriority - ) - ) - testPlanVersionsByHashedTests[hash].find( - obj => obj.id === testPlanVersion.id - ).isPriority = true; - } - } - } - } - } - - for (const key in testPlanVersionsByHashedTests) { - testPlanVersionsByHashedTests[key] - .sort((a, b) => { - const dateA = new Date(a.updatedAt); - const dateB = new Date(b.updatedAt); - return dateA - dateB; - }) - .sort((a, b) => { - return a.isPriority ? -1 : b.isPriority ? 1 : 0; - }); - } - - const batchesWIsPriority = {}; - const batchesWOIsPriority = {}; - - for (const hash in testPlanVersionsByHashedTests) { - const batch = testPlanVersionsByHashedTests[hash]; - - if (batch.some(testPlanVersion => testPlanVersion.isPriority)) { - batchesWIsPriority[hash] = batch; - } else { - batchesWOIsPriority[hash] = batch; - } - } - - const getTestPlanVersionIdsByHashedTests = data => { - const getIdsFromKey = key => { - return data[key].map(item => item.id); - }; - - // Get the ids for each key - const idsByKeys = {}; - Object.keys(data).forEach(key => { - idsByKeys[key] = getIdsFromKey(key); - }); - - return idsByKeys; - }; - - const testPlanVersionIdsByHashedTests = - getTestPlanVersionIdsByHashedTests(testPlanVersionsByHashedTests); - const testPlanVersionIdsByHashedTestsToKeep = - getTestPlanVersionIdsByHashedTests(batchesWIsPriority); - const testPlanVersionIdsByHashedTestsToDelete = - getTestPlanVersionIdsByHashedTests(batchesWOIsPriority); - - return { - testPlanVersionIdsByHashedTests, - testPlanVersionIdsByHashedTestsToKeep, - testPlanVersionIdsByHashedTestsToDelete - }; - }; - - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanVersion', - 'hashedTests', - { type: Sequelize.DataTypes.TEXT }, - { transaction } - ); - - // Get the unique TestPlanVersions found for each hash - const { testPlanVersionsByHashedTests } = - await computeTestPlanVersionHashedTests(transaction); - - const uniqueHashCount = Object.keys(testPlanVersionsByHashedTests).length; - const testPlanReportsBatchSize = 100; - const iterationsNeeded = Math.ceil( - uniqueHashCount / testPlanReportsBatchSize - ); - - // Retrieve the latest known git commits info for each test plan directory - const knownGitCommits = await getKnownGitCommits(); - - const { - testPlanVersionIdsByHashedTests, - testPlanVersionIdsByHashedTestsToDelete - } = processTestPlanVersionIdsByHashedTests( - testPlanVersionsByHashedTests, - knownGitCommits - ); - - const testPlanVersionIdsToDelete = Object.values( - testPlanVersionIdsByHashedTestsToDelete - ); - - for (let i = 0; i < iterationsNeeded; i += 1) { - // eslint-disable-next-line no-console - console.info( - 'Fixing TestPlanReports', - i * testPlanReportsBatchSize, - 'of', - uniqueHashCount - ); - - const offset = i * testPlanReportsBatchSize; - const equivalentIds = Object.values( - testPlanVersionIdsByHashedTests - ).slice( - offset, - Math.min(offset + testPlanReportsBatchSize, uniqueHashCount) - ); - - // Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults - await regenerateExistingTestResults(equivalentIds, transaction); - - await removeTestPlanVersionDuplicates(equivalentIds, transaction); - } - - // Remove the TestPlanVersions not captured by removeTestPlanVersionDuplicates() - if (testPlanVersionIdsToDelete.length) { - // Update TestPlanVersion -> TestPlanReport fkey to add cascade deletion on - // TestPlanVersion row deletion - await queryInterface.sequelize.query( - `alter table "TestPlanReport" - drop constraint "TestPlanReport_testPlan_fkey"; - - alter table "TestPlanReport" - add constraint "TestPlanReport_testPlan_fkey" foreign key ("testPlanVersionId") references "TestPlanVersion" on update cascade on delete cascade;`, - { - transaction - } - ); - - const toRemove = testPlanVersionIdsToDelete.flat(); - await queryInterface.sequelize.query( - `DELETE FROM "TestPlanVersion" WHERE id IN (?)`, - { - replacements: [toRemove], - transaction - } - ); - - // Update TestPlanVersion -> TestPlanReport fkey to remove cascade delete on - // TestPlanVersion row deletion - await queryInterface.sequelize.query( - `alter table "TestPlanReport" - drop constraint "TestPlanReport_testPlan_fkey"; - - alter table "TestPlanReport" - add constraint "TestPlanReport_testPlan_fkey" foreign key ("testPlanVersionId") references "TestPlanVersion" on update cascade;`, - { - transaction - } - ); - - if (uniqueHashCount) { - // eslint-disable-next-line no-console - console.info( - 'Fixed', - uniqueHashCount - testPlanVersionIdsToDelete.length, - 'of', - uniqueHashCount - testPlanVersionIdsToDelete.length - ); - } - } else if (uniqueHashCount) { - // eslint-disable-next-line no-console - console.info('Fixed', uniqueHashCount, 'of', uniqueHashCount); - } - - await queryInterface.changeColumn( - 'TestPlanVersion', - 'hashedTests', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - unique: true - }, - { transaction } - ); - }); - }, - - async down(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanVersion', 'hashedTests', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20230523163855-addColumnsToAtBrowsers.js b/server/migrations/20230523163855-addColumnsToAtBrowsers.js deleted file mode 100644 index 4e0a0dd1d..000000000 --- a/server/migrations/20230523163855-addColumnsToAtBrowsers.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'AtBrowsers', - 'isCandidate', - { - type: Sequelize.DataTypes.BOOLEAN, - allowNull: false - }, - { transaction } - ); - - await queryInterface.addColumn( - 'AtBrowsers', - 'isRecommended', - { - type: Sequelize.DataTypes.BOOLEAN, - allowNull: false - }, - { transaction } - ); - }); - }, - - async down(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('AtBrowsers', 'isCandidate', { - transaction - }); - await queryInterface.removeColumn('AtBrowsers', 'isRecommended', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20230523163856-remove-OtherUnexpectedBehaviorText.js b/server/migrations/20230523163856-remove-OtherUnexpectedBehaviorText.js deleted file mode 100644 index 27bf61816..000000000 --- a/server/migrations/20230523163856-remove-OtherUnexpectedBehaviorText.js +++ /dev/null @@ -1,167 +0,0 @@ -'use strict'; -const { - updateTestPlanRunById -} = require('../models/services/TestPlanRunService'); -const { - updateTestPlanReportById, - getTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const conflictsResolver = require('../resolvers/TestPlanReport/conflictsResolver'); -const { TEST_PLAN_REPORT_ATTRIBUTES } = require('../models/services/helpers'); -const getGraphQLContext = require('../graphql-context'); - -module.exports = { - up: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanRunQuery = await queryInterface.sequelize.query( - `SELECT id, "testResults" FROM "TestPlanRun"`, - { - transaction - } - ); - - const testPlanReportQuery = await queryInterface.sequelize.query( - `SELECT id, status FROM "TestPlanReport"`, - { - transaction - } - ); - - const testPlanRunData = testPlanRunQuery[0]; - const testPlanReportsData = testPlanReportQuery[0]; - if (!testPlanRunData) { - // eslint-disable-next-line no-console - console.info('The test Results are empty'); - return; - } - - for (let i = 0; i < testPlanRunData.length; i += 1) { - const testPlanRun = testPlanRunData[i]; - const testPlanRunId = testPlanRun.id; - let needsUpdate = false; - - let updateParams = { - testResults: testPlanRun.testResults - }; - - if (!testPlanRunData[i].testResults) { - continue; - } - if ( - Array.isArray(testPlanRunData[i].testResults) && - testPlanRunData[i].testResults.length < 1 - ) { - continue; - } - - for (let j = 0; j < testPlanRunData[i].testResults.length; j += 1) { - if (!testPlanRunData[i].testResults[j].scenarioResults) { - continue; - } - if ( - Array.isArray(testPlanRunData[i].testResults[j].scenarioResults) && - testPlanRunData[i].testResults[j].scenarioResults.length < 1 - ) { - continue; - } - for ( - let p = 0; - p < testPlanRunData[i].testResults[j].scenarioResults.length; - p += 1 - ) { - if ( - !testPlanRunData[i].testResults[j].scenarioResults[p] - .unexpectedBehaviors - ) { - continue; - } - - if ( - Array.isArray( - testPlanRunData[i].testResults[j].scenarioResults[p] - .unexpectedBehaviors - ) && - testPlanRunData[i].testResults[j].scenarioResults[p] - .unexpectedBehaviors.length < 1 - ) { - continue; - } - for ( - let s = 0; - s < - testPlanRunData[i].testResults[j].scenarioResults[p] - .unexpectedBehaviors.length; - s += 1 - ) { - const unexpectedBehavior = - testPlanRunData[i].testResults[j].scenarioResults[p] - .unexpectedBehaviors[s]; - if ( - unexpectedBehavior.id !== 'OTHER' && - unexpectedBehavior.otherUnexpectedBehaviorText === null - ) { - delete unexpectedBehavior.otherUnexpectedBehaviorText; - - updateParams.testResults[j] = testPlanRunData[i].testResults[j]; - - needsUpdate = true; - } - } - } - } - - if (needsUpdate) { - // eslint-disable-next-line no-console - console.info( - `=== Fixing unexpectedBehavior results for TestPlanRun:${testPlanRunId} ===` - ); - await updateTestPlanRunById({ - id: testPlanRunId, - values: updateParams, - transaction - }); - } - } - - // Exclude certain attributes called in testPlanReport query; - // needed to support future migrations - const testPlanReportAttributes = TEST_PLAN_REPORT_ATTRIBUTES.filter( - e => !['markedFinalAt'].includes(e) - ); - - for (let i = 0; i < testPlanReportsData.length; i++) { - const testPlanReportId = testPlanReportsData[i].id; - const status = testPlanReportsData[i].status; - if (status === 'DRAFT') { - let updateParams = {}; - const testPlanReport = await getTestPlanReportById({ - id: testPlanReportId, - testPlanReportAttributes, - testPlanVersionAttributes: ['id', 'tests'], - transaction - }); - - const conflicts = await conflictsResolver( - testPlanReport, - null, - context - ); - - updateParams = { - metrics: { - conflictsCount: conflicts.length - } - }; - - await updateTestPlanReportById({ - id: testPlanReport.id, - values: updateParams, - transaction - }); - } - } - }); - } -}; diff --git a/server/migrations/20230608170853-addDateColumnsToTestPlanVersion.js b/server/migrations/20230608170853-addDateColumnsToTestPlanVersion.js deleted file mode 100644 index 555008e81..000000000 --- a/server/migrations/20230608170853-addDateColumnsToTestPlanVersion.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanVersion', - 'phase', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - defaultValue: 'DRAFT' - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanVersion', - 'draftPhaseReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanVersion', - 'candidatePhaseReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanVersion', - 'recommendedPhaseReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanVersion', - 'recommendedPhaseTargetDate', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanVersion', - 'deprecatedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - }); - }, - - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanVersion', 'phase', { - transaction - }); - await queryInterface.removeColumn( - 'TestPlanVersion', - 'draftPhaseReachedAt', - { - transaction - } - ); - await queryInterface.removeColumn( - 'TestPlanVersion', - 'candidatePhaseReachedAt', - { - transaction - } - ); - await queryInterface.removeColumn( - 'TestPlanVersion', - 'recommendedPhaseReachedAt', - { - transaction - } - ); - await queryInterface.removeColumn( - 'TestPlanVersion', - 'recommendedPhaseTargetDate', - { - transaction - } - ); - await queryInterface.removeColumn('TestPlanVersion', 'deprecatedAt', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js b/server/migrations/20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js deleted file mode 100644 index d17f6138c..000000000 --- a/server/migrations/20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn( - 'TestPlanReport', - 'candidateStatusReachedAt', - 'markedFinalAt', - { transaction } - ); - await queryInterface.removeColumn( - 'TestPlanReport', - 'recommendedStatusReachedAt', - { - transaction - } - ); - await queryInterface.removeColumn( - 'TestPlanReport', - 'recommendedStatusTargetDate', - { - transaction - } - ); - }); - }, - - async down(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.renameColumn( - 'TestPlanReport', - 'markedFinalAt', - 'candidateStatusReachedAt', - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanReport', - 'recommendedStatusReachedAt', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanReport', - 'recommendedStatusTargetDate', - { - type: Sequelize.DataTypes.DATE, - defaultValue: null, - allowNull: true - }, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js b/server/migrations/20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js deleted file mode 100644 index 282753c78..000000000 --- a/server/migrations/20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.changeColumn( - 'TestPlanVersion', - 'phase', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - defaultValue: 'RD' - }, - { transaction } - ); - - // Need to get all the testPlanVersions that don't have testPlanReports attached to them - // to consider them as just being R&D Complete, but not yet in the DRAFT phase - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT - "TestPlanVersion".id, - "TestPlanVersion"."updatedAt", - CASE - WHEN COUNT("TestPlanReport".id) = 0 THEN false - ELSE true - END AS "hasTestPlanReport" - FROM "TestPlanVersion" - LEFT JOIN "TestPlanReport" ON "TestPlanVersion".id = "TestPlanReport"."testPlanVersionId" - GROUP BY "TestPlanVersion".id;`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanVersion of testPlanVersions) { - const { id, updatedAt, hasTestPlanReport } = testPlanVersion; - - if (hasTestPlanReport) { - const draftPhaseReachedAt = new Date(updatedAt); - draftPhaseReachedAt.setSeconds( - // Set draftPhaseReachedAt to happen 60 seconds after updatedAt for general - // 'correctness' and to help with any app sorts - draftPhaseReachedAt.getSeconds() + 60 - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET "draftPhaseReachedAt" = ? WHERE id = ?`, - { - replacements: [draftPhaseReachedAt, id], - transaction - } - ); - } else - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET phase = ? WHERE id = ?`, - { - replacements: ['RD', id], - transaction - } - ); - } - }); - }, - - async down(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.changeColumn( - 'TestPlanVersion', - 'phase', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false, - defaultValue: 'DRAFT' - }, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20230719174358-removeTestPlanReportStatus.js b/server/migrations/20230719174358-removeTestPlanReportStatus.js deleted file mode 100644 index bb01c1dac..000000000 --- a/server/migrations/20230719174358-removeTestPlanReportStatus.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanReport', 'status', { - transaction - }); - }); - }, - - async down(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'status', - { - type: Sequelize.DataTypes.TEXT, - defaultValue: 'DRAFT', - allowNull: false - }, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20230823212533-addCollectionJobs.js b/server/migrations/20230823212533-addCollectionJobs.js deleted file mode 100644 index 637754986..000000000 --- a/server/migrations/20230823212533-addCollectionJobs.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('CollectionJob', { - id: { - type: Sequelize.STRING, - allowNull: false, - primaryKey: true - }, - status: { - type: Sequelize.STRING, - allowNull: false, - defaultValue: 'QUEUED' - }, - externalLogsUrl: { - type: Sequelize.STRING, - allowNull: true, - defaultValue: null - }, - testPlanRunId: { - type: Sequelize.INTEGER, - references: { - model: 'TestPlanRun', - key: 'id' - }, - allowNull: true, - onDelete: 'SET NULL', - unique: true - } - }); - }, - down: async queryInterface => { - return queryInterface.dropTable('CollectionJob'); - } -}; diff --git a/server/migrations/20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js b/server/migrations/20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js deleted file mode 100644 index 35387aa4b..000000000 --- a/server/migrations/20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js +++ /dev/null @@ -1,159 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - // Check for all instances of TestPlanVersions that have "markedAsFinal" reports - // and in the DRAFT phase, and set those to CANDIDATE (so they can be shown as having - // reports been generated for them even though they are now deprecated) - // - // Eg. 281 (Disclosure Navigation) and - // 1178 (Radio Group Example Using aria-activedescendant) TestPlanVersions - const testPlanVersionsToSetToCandidate = - await queryInterface.sequelize.query( - `select "TestPlanVersion".id, phase, "draftPhaseReachedAt", "markedFinalAt" - from "TestPlanVersion" - join "TestPlanReport" on "TestPlanVersion".id = "TestPlanReport"."testPlanVersionId" - where "markedFinalAt" is not null - and phase = 'DRAFT';`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanVersion of testPlanVersionsToSetToCandidate) { - const candidatePhaseReachedAt = new Date( - testPlanVersion.draftPhaseReachedAt - ); - - // Set candidatePhaseReachedAt to draftPhaseReachedAt date (+1 day) - candidatePhaseReachedAt.setDate(candidatePhaseReachedAt.getDate() + 1); - - const recommendedPhaseTargetDate = new Date(candidatePhaseReachedAt); - recommendedPhaseTargetDate.setDate( - candidatePhaseReachedAt.getDate() + 180 - ); - - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "candidatePhaseReachedAt" = ?, - "recommendedPhaseTargetDate" = ?, - phase = 'CANDIDATE' - where id = ?`, - { - replacements: [ - candidatePhaseReachedAt, - recommendedPhaseTargetDate, - testPlanVersion.id - ], - transaction - } - ); - } - - // Check for instances of all older TestPlanVersions and deprecate them - const testPlanVersions = await queryInterface.sequelize.query( - `select id, directory, "updatedAt", "draftPhaseReachedAt", "candidatePhaseReachedAt", "recommendedPhaseReachedAt", "deprecatedAt" - from "TestPlanVersion" - order by directory, "updatedAt";`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - // Group objects by directory - const groupedData = {}; - for (const testPlanVersion of testPlanVersions) { - if (!groupedData[testPlanVersion.directory]) { - groupedData[testPlanVersion.directory] = []; - } - groupedData[testPlanVersion.directory].push(testPlanVersion); - } - - // Update "deprecatedAt" based on next object's "updatedAt" - for (const directory in groupedData) { - const objects = groupedData[directory]; - for (let i = 0; i < objects.length - 1; i++) { - objects[i].deprecatedAt = objects[i + 1].updatedAt; - } - } - - // Flatten the grouped data back into a single array - const flattenedTestPlanVersions = Object.values(groupedData).reduce( - (acc, objects) => acc.concat(objects), - [] - ); - - for (let testPlanVersion of flattenedTestPlanVersions) { - // Check for the instances where candidatePhaseReachedAt is shown as happening - // before draftPhaseReachedAt - if ( - testPlanVersion.draftPhaseReachedAt && - testPlanVersion.candidatePhaseReachedAt - ) { - let draftPhaseReachedAt = new Date( - testPlanVersion.draftPhaseReachedAt - ); - let candidatePhaseReachedAt = new Date( - testPlanVersion.candidatePhaseReachedAt - ); - - // Update candidatePhaseReachedAt to be the draftPhaseReachedAt date (+1 day) - // (because that phase happening before shouldn't be possible) - if (candidatePhaseReachedAt < draftPhaseReachedAt) { - const newCandidatePhaseReachedAt = new Date(draftPhaseReachedAt); - newCandidatePhaseReachedAt.setDate( - newCandidatePhaseReachedAt.getDate() + 1 - ); - - testPlanVersion.candidatePhaseReachedAt = - newCandidatePhaseReachedAt; - - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "candidatePhaseReachedAt" = ? - where id = ?`, - { - replacements: [ - testPlanVersion.candidatePhaseReachedAt, - testPlanVersion.id - ], - transaction - } - ); - } - } - - if (testPlanVersion.deprecatedAt) { - const deprecatedAt = new Date(testPlanVersion.deprecatedAt); - deprecatedAt.setSeconds(deprecatedAt.getSeconds() - 1); - - // Add deprecatedAt for applicable testPlanVersions - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "deprecatedAt" = ?, - phase = 'DEPRECATED' - where id = ?`, - { - replacements: [deprecatedAt, testPlanVersion.id], - transaction - } - ); - } - } - }); - }, - - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "deprecatedAt" = null;`, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20230927172432-addVersionStrings.js b/server/migrations/20230927172432-addVersionStrings.js deleted file mode 100644 index 43441dd6a..000000000 --- a/server/migrations/20230927172432-addVersionStrings.js +++ /dev/null @@ -1,85 +0,0 @@ -const convertDateToString = require('../util/convertDateToString'); - -('use strict'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanVersion', - 'versionString', - { type: Sequelize.DataTypes.TEXT }, - { transaction } - ); - - const [testPlanVersions] = await queryInterface.sequelize.query( - ` - SELECT id, directory, "updatedAt" - FROM "TestPlanVersion" - ORDER BY directory, "updatedAt", id - `, - { transaction } - ); - - let currentDirectory; - let currentVersionStringBase; - let currentCount; - for (const testPlanVersion of testPlanVersions) { - const versionStringBase = `V${convertDateToString( - testPlanVersion.updatedAt, - 'YY.MM.DD' - )}`; - - if (testPlanVersion.directory !== currentDirectory) { - currentDirectory = testPlanVersion.directory; - currentVersionStringBase = versionStringBase; - currentCount = 0; - } else if (versionStringBase === currentVersionStringBase) { - currentCount += 1; - } else { - currentVersionStringBase = versionStringBase; - currentCount = 0; - } - - const versionString = - currentCount === 0 - ? currentVersionStringBase - : `${currentVersionStringBase}-${currentCount}`; - - await queryInterface.sequelize.query( - ` - UPDATE "TestPlanVersion" - SET "versionString" = ? - WHERE id = ? - `, - { - replacements: [versionString, testPlanVersion.id], - transaction - } - ); - } - - await queryInterface.changeColumn( - 'TestPlanVersion', - 'versionString', - { - type: Sequelize.DataTypes.TEXT, - allowNull: false - }, - { transaction } - ); - - await queryInterface.addConstraint('TestPlanVersion', { - fields: ['directory', 'versionString'], - type: 'unique', - name: 'uniqueVersionStringByDirectory', - transaction - }); - }); - }, - - async down(queryInterface /* , Sequelize */) { - await queryInterface.removeColumn('TestPlanVersion', 'versionString'); - } -}; diff --git a/server/migrations/20230927230957-add-initiatedByAutomation-to-testPlanRun.js b/server/migrations/20230927230957-add-initiatedByAutomation-to-testPlanRun.js deleted file mode 100644 index 0d06f9893..000000000 --- a/server/migrations/20230927230957-add-initiatedByAutomation-to-testPlanRun.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - up: async (queryInterface, Sequelize) => { - await queryInterface.addColumn('TestPlanRun', 'initiatedByAutomation', { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - }); - }, - down: async queryInterface => { - await queryInterface.removeColumn('TestPlanRun', 'initiatedByAutomation'); - } -}; diff --git a/server/migrations/20231031162340-verifyNoSkippedTests.js b/server/migrations/20231031162340-verifyNoSkippedTests.js deleted file mode 100644 index 18ca9b562..000000000 --- a/server/migrations/20231031162340-verifyNoSkippedTests.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - const [rows] = await queryInterface.sequelize.query( - ` - SELECT - "TestPlanReport".id, - "TestPlanReport"."atId", - "TestPlanRun"."testResults", - "TestPlanVersion".tests - FROM - "TestPlanReport" - INNER JOIN "TestPlanVersion" ON "TestPlanVersion".id = "TestPlanReport"."testPlanVersionId" - INNER JOIN "TestPlanRun" ON "TestPlanReport".id = "TestPlanRun"."testPlanReportId" - WHERE - "TestPlanReport"."markedFinalAt" IS NOT NULL - `, - { transaction } - ); - - const dataById = {}; - rows.forEach(({ id, atId, testResults, tests }) => { - if (dataById[id]) { - dataById[id].runLengths.push(testResults.length); - } else { - const runnableTestsLength = tests.filter(test => - test.atIds.includes(atId) - ).length; - dataById[id] = { - id, - runnableTestsLength, - runLengths: [testResults.length] - }; - } - }); - - for (const data of Object.values(dataById)) { - const isComplete = data.runLengths.every( - runLength => runLength === data.runnableTestsLength - ); - if (!isComplete) { - console.info(`Found incomplete report ${data.id}`); // eslint-disable-line - // Since final test plan reports can - // no longer have skipped tests, we should - // move them to the test queue where incomplete - // runs are still supported. - await queryInterface.sequelize.query( - ` - UPDATE "TestPlanReport" SET "markedFinalAt" = NULL WHERE id = ? - `, - { - replacements: [data.id], - transaction - } - ); - } - } - }); - } -}; diff --git a/server/migrations/20231114170315-addScreenTextAndInstructionsToAtMode.js b/server/migrations/20231114170315-addScreenTextAndInstructionsToAtMode.js deleted file mode 100644 index 6502b6e3e..000000000 --- a/server/migrations/20231114170315-addScreenTextAndInstructionsToAtMode.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'AtMode', - 'screenText', - { type: Sequelize.DataTypes.TEXT }, - { transaction } - ); - - await queryInterface.addColumn( - 'AtMode', - 'instructions', - { type: Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.TEXT) }, - { transaction } - ); - }); - }, - - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('AtMode', 'screenText', { - transaction - }); - - await queryInterface.removeColumn('AtMode', 'instructions', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js b/server/migrations/20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js deleted file mode 100644 index 73ee6da21..000000000 --- a/server/migrations/20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - const [testPlanRuns] = await queryInterface.sequelize.query( - `select id, "testResults" from "TestPlanRun"`, - { - transaction - } - ); - - for (let testPlanRun of testPlanRuns) { - let needsUpdate = false; - let testResultsToUpdate = []; - - for (let testResult of testPlanRun.testResults) { - for (let scenarioResult of testResult.scenarioResults) { - if (scenarioResult.unexpectedBehaviors) { - for (let unexpectedBehavior of scenarioResult.unexpectedBehaviors) { - // Will only apply if unexpectedBehavior.id = OTHER - if (unexpectedBehavior.otherUnexpectedBehaviorText) - unexpectedBehavior.details = - unexpectedBehavior.otherUnexpectedBehaviorText; - - // Default impact to Moderate - if (!unexpectedBehavior.impact) - unexpectedBehavior.impact = 'MODERATE'; - - // Default the text to N/A. Text content is required - if (!unexpectedBehavior.details) - unexpectedBehavior.details = 'N/A'; - - delete unexpectedBehavior.otherUnexpectedBehaviorText; - } - needsUpdate = true; - } - } - - testResultsToUpdate.push(testResult); - } - - if (needsUpdate) { - await queryInterface.sequelize.query( - `update "TestPlanRun" set "testResults" = ? where id = ?`, - { - replacements: [ - JSON.stringify(testResultsToUpdate), - testPlanRun.id - ], - transaction - } - ); - } - } - }); - } -}; diff --git a/server/migrations/20231219212344-recalculateV2TestHashes.js b/server/migrations/20231219212344-recalculateV2TestHashes.js deleted file mode 100644 index ce0b4bb02..000000000 --- a/server/migrations/20231219212344-recalculateV2TestHashes.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await regenerateResultsAndRecalculateHashes(queryInterface, transaction, { - testPlanVersionWhere: `WHERE metadata->>'testFormatVersion' = '2'` - }); - }); - } -}; diff --git a/server/migrations/20240104150500-includeAdditionalTestFormatVersionAttributes.js b/server/migrations/20240104150500-includeAdditionalTestFormatVersionAttributes.js deleted file mode 100644 index 8c84a6ea2..000000000 --- a/server/migrations/20240104150500-includeAdditionalTestFormatVersionAttributes.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - const updateV1TestPlanVersionsToIncludeTestFormatVersion = - async transaction => { - // No testFormatVersion indicates this is v1 TestPlanVersion data - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, metadata FROM "TestPlanVersion" WHERE metadata->>'testFormatVersion' IS NULL`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - await Promise.all( - testPlanVersions.map(async ({ id, metadata }) => { - const updatedMetadata = JSON.stringify({ - ...metadata, - testFormatVersion: 1 - }); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET metadata = ? WHERE id = ?`, - { replacements: [updatedMetadata, id], transaction } - ); - }) - ); - }; - - const updateTestPlanVersionTestsToIncludeTestFormatVersion = - async transaction => { - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests, metadata FROM "TestPlanVersion"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - await Promise.all( - testPlanVersions.map(async ({ id, tests, metadata }) => { - const testFormatVersion = metadata.testFormatVersion; - const updatedTests = JSON.stringify( - tests.map(test => ({ ...test, testFormatVersion })) - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET tests = ? WHERE id = ?`, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - }; - - return queryInterface.sequelize.transaction(async transaction => { - // Include testFormatVersion inside TestPlanVersion.metadata for v1 test plan versions - await updateV1TestPlanVersionsToIncludeTestFormatVersion(transaction); - - // Include testFormatVersion for each test inside TestPlanVersion.tests - await updateTestPlanVersionTestsToIncludeTestFormatVersion(transaction); - - // Recalculate the hashes - await regenerateResultsAndRecalculateHashes(queryInterface, transaction); - }); - } -}; diff --git a/server/migrations/20240111225130-includeMissingAssertionExceptions.js b/server/migrations/20240111225130-includeMissingAssertionExceptions.js deleted file mode 100644 index 349740108..000000000 --- a/server/migrations/20240111225130-includeMissingAssertionExceptions.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - const updateV2TestsToIncludeEmptyAssertionExceptions = - async transaction => { - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion" WHERE metadata->>'testFormatVersion' = '2'`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - await Promise.all( - testPlanVersions.map(async ({ id, tests }) => { - const updatedTests = JSON.stringify( - tests.map(test => { - test.assertions = test.assertions.map(assertion => ({ - ...assertion, - assertionExceptions: [] - })); - return test; - }) - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET tests = ? WHERE id = ?`, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - }; - - return queryInterface.sequelize.transaction(async transaction => { - await updateV2TestsToIncludeEmptyAssertionExceptions(transaction); - - // Recalculate the hashes - await regenerateResultsAndRecalculateHashes(queryInterface, transaction); - }); - } -}; diff --git a/server/migrations/20240215220201-updateMetricsForCountingUnexpectedBehaviors.js b/server/migrations/20240215220201-updateMetricsForCountingUnexpectedBehaviors.js deleted file mode 100644 index f653f7dd2..000000000 --- a/server/migrations/20240215220201-updateMetricsForCountingUnexpectedBehaviors.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -const { getMetrics } = require('shared'); -const populateData = require('../services/PopulatedData/populateData'); -const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); -const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); -const { - updateTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const getGraphQLContext = require('../graphql-context'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanReports = await queryInterface.sequelize.query( - `SELECT id, metrics FROM "TestPlanReport"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanReport of testPlanReports) { - const { testPlanReport: testPlanReportPopulated } = await populateData( - { testPlanReportId: testPlanReport.id }, - { context } - ); - const runnableTests = runnableTestsResolver( - testPlanReportPopulated, - null, - context - ); - const finalizedTestResults = await finalizedTestResultsResolver( - testPlanReportPopulated, - null, - context - ); - const metrics = getMetrics({ - testPlanReport: { - ...testPlanReportPopulated, - finalizedTestResults, - runnableTests - } - }); - await updateTestPlanReportById({ - id: testPlanReportPopulated.id, - values: { - metrics: { - ...testPlanReportPopulated.metrics, - ...metrics - } - }, - transaction - }); - } - }); - } -}; diff --git a/server/migrations/20240224173914-includeAssertionIdInTestAssertions.js b/server/migrations/20240224173914-includeAssertionIdInTestAssertions.js deleted file mode 100644 index 0f80d2fda..000000000 --- a/server/migrations/20240224173914-includeAssertionIdInTestAssertions.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion" WHERE metadata->>'testFormatVersion' = '2'`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - await Promise.all( - testPlanVersions.map(async ({ id, tests }) => { - const updatedTests = JSON.stringify( - tests.map(test => { - test.assertions = test.assertions.map(assertion => ({ - id: assertion.id, - rawAssertionId: test.renderableContent.assertions.find( - otherAssertion => - otherAssertion.assertionStatement === - assertion.assertionStatement - ).assertionId, - ...assertion - })); - return test; - }) - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET tests = ? WHERE id = ?`, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - - await regenerateResultsAndRecalculateHashes(queryInterface, transaction, { - pruneOldVersions: false - }); - }); - } -}; diff --git a/server/migrations/20240229195433-modifyCollectionJobIdType.js b/server/migrations/20240229195433-modifyCollectionJobIdType.js deleted file mode 100644 index 1ddd16cfa..000000000 --- a/server/migrations/20240229195433-modifyCollectionJobIdType.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - // Drop the primary key constraint to enable changing the 'id' column type - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" DROP CONSTRAINT "CollectionJob_pkey";`, - { transaction } - ); - - // Change the 'id' column type to INTEGER - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ALTER COLUMN "id" TYPE INTEGER USING ("id"::integer);`, - { transaction } - ); - - // Create a sequence for auto-increment - await queryInterface.sequelize.query( - `CREATE SEQUENCE collectionjob_id_seq AS INTEGER;`, - { transaction } - ); - - // Set the default value of 'id' to the next value of the sequence - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ALTER COLUMN "id" SET DEFAULT nextval('collectionjob_id_seq');`, - { transaction } - ); - - // Set the sequence as the owner of the 'id' column - await queryInterface.sequelize.query( - `ALTER SEQUENCE collectionjob_id_seq OWNED BY "CollectionJob"."id";`, - { transaction } - ); - - // Ensure that the sequence starts from the next value of the current maximum 'id' - await queryInterface.sequelize.query( - ` - SELECT setval(pg_get_serial_sequence('"CollectionJob"', 'id'), - COALESCE((SELECT MAX("id") FROM "CollectionJob"), 0) + 1); - `, - { transaction } - ); - - // Add the primary key constraint back - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ADD PRIMARY KEY ("id");`, - { transaction } - ); - }); - }, - - async down(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - // Remove the primary key constraint - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" DROP CONSTRAINT "CollectionJob_pkey";`, - { transaction } - ); - - // Remove the default value from the 'id' column - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ALTER COLUMN "id" DROP DEFAULT;`, - { transaction } - ); - - // Drop the sequence created for auto-increment - await queryInterface.sequelize.query( - `DROP SEQUENCE collectionjob_id_seq;`, - { transaction } - ); - - // Revert the 'id' column back to STRING - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ALTER COLUMN "id" TYPE VARCHAR USING ("id"::text);`, - { transaction } - ); - - // Add the primary key constraint back - await queryInterface.sequelize.query( - `ALTER TABLE "CollectionJob" ADD PRIMARY KEY ("id");`, - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20240305205951-removeAtMode.js b/server/migrations/20240305205951-removeAtMode.js deleted file mode 100644 index 3401207b6..000000000 --- a/server/migrations/20240305205951-removeAtMode.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.dropTable('AtMode', { - cascade: true, - transaction - }); - - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - await Promise.all( - testPlanVersions.map(async ({ id, tests }) => { - const updatedTests = JSON.stringify( - tests.map(test => { - delete test.atMode; - return test; - }) - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET tests = ? WHERE id = ?`, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - await regenerateResultsAndRecalculateHashes(queryInterface, transaction, { - pruneOldVersions: false - }); - }); - } -}; diff --git a/server/migrations/20240311192910-removeRequiredAndOptionalPriority.js b/server/migrations/20240311192910-removeRequiredAndOptionalPriority.js deleted file mode 100644 index 77e72836d..000000000 --- a/server/migrations/20240311192910-removeRequiredAndOptionalPriority.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const modifyPrioritiesInTable = async () => { - const testPlanVersions = await queryInterface.sequelize.query( - // This query is returning tests that have any assertions that - // have a priority value of REQUIRED or OPTIONAL. - ` - SELECT - id, - tests - FROM - "TestPlanVersion" - WHERE - EXISTS ( - SELECT - 1 - FROM - jsonb_array_elements(tests) AS test, - jsonb_array_elements(test -> 'assertions') AS assertion - WHERE - assertion ->> 'priority' = 'REQUIRED' - OR assertion ->> 'priority' = 'OPTIONAL' - )`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - await Promise.all( - testPlanVersions.map(async ({ id, tests }) => { - const updatedTests = JSON.stringify( - tests.map(test => { - return { - ...test, - assertions: test.assertions.map(assertion => { - if (assertion.priority === 'REQUIRED') { - assertion.priority = 'MUST'; - } else if (assertion.priority === 'OPTIONAL') { - assertion.priority = 'SHOULD'; - } - - return { - ...assertion - }; - }) - }; - }) - ); - await queryInterface.sequelize.query( - ` - UPDATE - "TestPlanVersion" - SET - tests = ? - WHERE - id = ? - `, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - }; - await modifyPrioritiesInTable(); - }); - }, - down: async () => {} -}; diff --git a/server/migrations/20240312122457-testPlanReportAtVersions.js b/server/migrations/20240312122457-testPlanReportAtVersions.js deleted file mode 100644 index a0f98e279..000000000 --- a/server/migrations/20240312122457-testPlanReportAtVersions.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanReport', - 'exactAtVersionId', - { type: Sequelize.DataTypes.INTEGER }, - { transaction } - ); - - await queryInterface.addColumn( - 'TestPlanReport', - 'minimumAtVersionId', - { type: Sequelize.DataTypes.INTEGER }, - { transaction } - ); - - const atVersions = await queryInterface.sequelize.query( - ` - SELECT - id, - "atId", - "releasedAt" - FROM - "AtVersion" - ORDER BY - "releasedAt" ASC - `, - { type: Sequelize.QueryTypes.SELECT, transaction } - ); - - const oldAtVersions = {}; - atVersions.forEach(atVersion => { - if (!oldAtVersions[atVersion.atId]) { - oldAtVersions[atVersion.atId] = atVersion.id; - } - }); - - for (const [atId, atVersionId] of Object.entries(oldAtVersions)) { - await queryInterface.sequelize.query( - ` - UPDATE - "TestPlanReport" - SET - "minimumAtVersionId" = ? - WHERE - "atId" = ? - `, - { replacements: [atVersionId, atId], transaction } - ); - } - }); - }, - - async down(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanReport', 'exactAtVersionId', { - transaction - }); - await queryInterface.removeColumn( - 'TestPlanReport', - 'minimumAtVersionId', - { transaction } - ); - }); - } -}; diff --git a/server/migrations/20240312131258-browserVersionReleasedAt.js b/server/migrations/20240312131258-browserVersionReleasedAt.js deleted file mode 100644 index 28abae55a..000000000 --- a/server/migrations/20240312131258-browserVersionReleasedAt.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'BrowserVersion', - 'releasedAt', - { - type: Sequelize.DataTypes.DATE, - allowNull: true - }, - { transaction } - ); - }); - }, - - async down(queryInterface /* , Sequelize */) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('AtVersion', 'releasedAt', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20240312145416-updateMetricsForUsingTotalCalculation.js b/server/migrations/20240312145416-updateMetricsForUsingTotalCalculation.js deleted file mode 100644 index f653f7dd2..000000000 --- a/server/migrations/20240312145416-updateMetricsForUsingTotalCalculation.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -const { getMetrics } = require('shared'); -const populateData = require('../services/PopulatedData/populateData'); -const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); -const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); -const { - updateTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const getGraphQLContext = require('../graphql-context'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanReports = await queryInterface.sequelize.query( - `SELECT id, metrics FROM "TestPlanReport"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanReport of testPlanReports) { - const { testPlanReport: testPlanReportPopulated } = await populateData( - { testPlanReportId: testPlanReport.id }, - { context } - ); - const runnableTests = runnableTestsResolver( - testPlanReportPopulated, - null, - context - ); - const finalizedTestResults = await finalizedTestResultsResolver( - testPlanReportPopulated, - null, - context - ); - const metrics = getMetrics({ - testPlanReport: { - ...testPlanReportPopulated, - finalizedTestResults, - runnableTests - } - }); - await updateTestPlanReportById({ - id: testPlanReportPopulated.id, - values: { - metrics: { - ...testPlanReportPopulated.metrics, - ...metrics - } - }, - transaction - }); - } - }); - } -}; diff --git a/server/migrations/20240313145124-addIsPrimaryColumnToTestPlanRun.js b/server/migrations/20240313145124-addIsPrimaryColumnToTestPlanRun.js deleted file mode 100644 index fa8291d2a..000000000 --- a/server/migrations/20240313145124-addIsPrimaryColumnToTestPlanRun.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'TestPlanRun', - 'isPrimary', - { - type: Sequelize.DataTypes.BOOLEAN, - allowNull: true, - defaultValue: false - }, - { transaction } - ); - }); - }, - - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('TestPlanRun', 'isPrimary', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20240319190618-updateCandidatePhaseReachedDates.js b/server/migrations/20240319190618-updateCandidatePhaseReachedDates.js deleted file mode 100644 index ecf392411..000000000 --- a/server/migrations/20240319190618-updateCandidatePhaseReachedDates.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const testPlanVersions = await queryInterface.sequelize.query( - `select id, "candidatePhaseReachedAt", "recommendedPhaseTargetDate", directory - from "TestPlanVersion" - where "candidatePhaseReachedAt" is not null - order by "candidatePhaseReachedAt"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - const testPlanVersionsByDirectory = {}; - for (const testPlanVersion of testPlanVersions) { - const { directory } = testPlanVersion; - - if (!testPlanVersionsByDirectory[directory]) - testPlanVersionsByDirectory[directory] = [testPlanVersion]; - else testPlanVersionsByDirectory[directory].push(testPlanVersion); - } - - for (const directory of Object.keys(testPlanVersionsByDirectory)) { - // No need to update since only that TestPlanVersion exists in CANDIDATE - if (directory.length === 1) continue; - - // Already pre sorted to have the earliest candidatePhaseStart date; works because - // no RECOMMENDED TestPlanVersions currently exist - const [firstTestPlanVersion, ...rest] = - testPlanVersionsByDirectory[directory]; - - for (const restTestPlanVersion of rest) { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "recommendedPhaseTargetDate" = ? - where id = ?`, - { - replacements: [ - firstTestPlanVersion.recommendedPhaseTargetDate, - restTestPlanVersion.id - ], - transaction - } - ); - } - } - }); - } -}; diff --git a/server/migrations/20240321182449-addKeyColumnToAtAndBrowserTables.js b/server/migrations/20240321182449-addKeyColumnToAtAndBrowserTables.js deleted file mode 100644 index ef54474a1..000000000 --- a/server/migrations/20240321182449-addKeyColumnToAtAndBrowserTables.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'At', - 'key', - { - type: Sequelize.DataTypes.TEXT - }, - { transaction } - ); - - await queryInterface.addColumn( - 'Browser', - 'key', - { - type: Sequelize.DataTypes.TEXT - }, - { transaction } - ); - }); - }, - - down: queryInterface => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('At', 'key', { - transaction - }); - await queryInterface.removeColumn('Browser', 'key', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20240325205951-cleanupDuplicatesAndRegenerateHashes.js b/server/migrations/20240325205951-cleanupDuplicatesAndRegenerateHashes.js deleted file mode 100644 index f39b2f91d..000000000 --- a/server/migrations/20240325205951-cleanupDuplicatesAndRegenerateHashes.js +++ /dev/null @@ -1,133 +0,0 @@ -'use strict'; - -const { regenerateResultsAndRecalculateHashes } = require('./utils'); -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - // Remove unnecessarily created test plan versions for ALL 35 test - // plan versions for commit, - // https://github.com/w3c/aria-at/commit/836fb2a997f5b2844035b8c934f8fda9833cd5b2 - // None of the following ever left R&D - await queryInterface.sequelize.query( - `delete - from "TestPlanVersion" - where id in - (55591, 55592, 55593, 55594, 55595, 55596, 55597, 55598, 55599, 55600, 55601, 55602, 55603, 55604, 55605, 55606, - 55607, 55608, 55609, 55610, 55611, 55612, 55613, 55614, 55615, 55616, 55617, 55618, 55619, 55620, 55621, 55622, - 55623, 55624, 55625) - and "gitSha" = '836fb2a997f5b2844035b8c934f8fda9833cd5b2'`, - { - transaction - } - ); - - // Reset the phases and remove deprecatedAt dates for versions affected by above wrongly created versions: - // checkbox-tri-state - // link-css - // link-img-alt - // main - // meter - // radiogroup-roving-tabindex - // slider-multithumb - // switch - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set phase = 'RD', - "deprecatedAt" = null - where id = 1566 and directory = 'switch' and "gitSha" = '9d0e4e3d1040d64d9db69647e615c4ec0be723c2' - or id = 1591 and directory = 'meter' and "gitSha" = '32d2d9db48becfc008fc566b569ac1563576ceb9' - or id = 1618 and directory = 'main' and "gitSha" = 'c87a66ea13a2b6fac6d79fe1fb0b7a2f721dcd22' - or id = 1798 and directory = 'checkbox-tri-state' and "gitSha" = 'b3d0576a2901ea7f100f49a994b64edbecf81cff' - or id = 2129 and directory = 'link-img-alt' and "gitSha" = 'dc637636cff74b51f5c468ff3b81bd1f38aefbb2' - or id = 2162 and directory = 'link-css' and "gitSha" = '7a8454bca6de980199868101431817cea03cce35' - or id = 2245 and directory = 'slider-multithumb' and "gitSha" = 'b5fe3efd569518e449ef9a0978b0dec1f2a08bd6' - or id = 2347 and directory = 'radiogroup-roving-tabindex' and "gitSha" = '1768070bd68beefef29284b568d2da910b449c14'`, - { - transaction - } - ); - - // Deprecate older uncaught instance of a 2nd DRAFT version - // Toggle Button V23.12.13 and set deprecatedAt to date of when - // newer Toggle Button V23.12.14 would have overwritten it, - // minus 2 seconds to simulate what would happen in - // updatePhaseResolver - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set phase = 'DEPRECATED', - "deprecatedAt" = '2023-12-14 21:51:35.527000 +00:00' - where id = 62309 - and directory = 'toggle-button' - and "versionString" = 'V23.12.13'`, - { - transaction - } - ); - - // Update Radio Group Example Using aria-activedescendant V24.03.13 to include the tokenized assertion phrase for JAWS and NVDA - // because it wasn't properly handled by the import script because #942 was not yet in production when version was imported - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion" WHERE directory = 'radiogroup-aria-activedescendant' AND "versionString" = 'V24.03.13'`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - await Promise.all( - testPlanVersions.map(async ({ id, tests }) => { - const updatedTests = JSON.stringify( - tests.map(test => { - const atKey = test.at.key; - if (atKey === 'voiceover_macos') return test; - - test.assertions.map(assertion => { - if ( - assertion.assertionPhrase !== - 'switch from reading mode to interaction mode' - ) - return assertion; - - if (atKey === 'jaws') - assertion.assertionPhrase = - 'switch from virtual cursor active to PC cursor active'; - if (atKey === 'nvda') - assertion.assertionPhrase = - 'switch from browse mode to focus mode'; - return assertion; - }); - - test.renderableContent.assertions.map(assertion => { - if ( - assertion.assertionPhrase !== - 'switch from reading mode to interaction mode' - ) - return assertion; - - if (atKey === 'jaws') - assertion.assertionPhrase = - 'switch from virtual cursor active to PC cursor active'; - if (atKey === 'nvda') - assertion.assertionPhrase = - 'switch from browse mode to focus mode'; - return assertion; - }); - - return test; - }) - ); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET tests = ? WHERE id = ?`, - { replacements: [updatedTests, id], transaction } - ); - }) - ); - - // Regenerate hashes since TestPlanVersion.tests modified - await regenerateResultsAndRecalculateHashes(queryInterface, transaction, { - pruneOldVersions: false - }); - }); - }, - async down() {} -}; diff --git a/server/migrations/20240401203810-fixCommandButtonPhaseChangeDate.js b/server/migrations/20240401203810-fixCommandButtonPhaseChangeDate.js deleted file mode 100644 index e9359005c..000000000 --- a/server/migrations/20240401203810-fixCommandButtonPhaseChangeDate.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - // Update date for Command Button V23.12.13 to be the time V22.04.04 - // was deprecated (+1 second) - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "candidatePhaseReachedAt" = '2024-01-24 02:06:55.460000 +00:00' - where id = 62353 - and "gitSha" = '565a87b4111acebdb883d187b581e82c42a73844' - and directory = 'command-button'`, - { - transaction - } - ); - - // Update deprecation date for Command Button V23.12.06 to be a - // second before its current time. It was the same time Command - // Button V23.12.13 was updated to draft which isn't functionally - // possible - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "deprecatedAt" = '2023-12-13 22:18:04.298000 +00:00' - where id = 56298 - and "gitSha" = 'd9a19f815d0f21194023b1c5919eb3b04d5c1ab7' - and directory = 'command-button'`, - { - transaction - } - ); - }); - }, - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "candidatePhaseReachedAt" = '2022-05-05 21:34:31.000000 +00:00' - where id = 62353 - and "gitSha" = '565a87b4111acebdb883d187b581e82c42a73844' - and directory = 'command-button'`, - { - transaction - } - ); - - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "deprecatedAt" = '2023-12-13 22:19:04.298000 +00:00' - where id = 56298 - and "gitSha" = 'd9a19f815d0f21194023b1c5919eb3b04d5c1ab7' - and directory = 'command-button'`, - { - transaction - } - ); - }); - } -}; diff --git a/server/migrations/20240404171101-addCollectionJobTestStatus.js b/server/migrations/20240404171101-addCollectionJobTestStatus.js deleted file mode 100644 index 390cd5794..000000000 --- a/server/migrations/20240404171101-addCollectionJobTestStatus.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.createTable( - 'CollectionJobTestStatus', - { - id: { - type: Sequelize.INTEGER, - primaryKey: true, - autoIncrement: true - }, - testId: { - type: Sequelize.STRING, - allowNull: false - }, - collectionJobId: { - type: Sequelize.INTEGER, - allowNull: false, - onDelete: 'CASCADE', - onUpdate: 'CASCADE', - references: { - model: 'CollectionJob', - key: 'id' - } - }, - status: { - type: Sequelize.STRING, - allowNull: false, - defaultValue: 'QUEUED' - } - }, - { transaction } - ); - await queryInterface.addConstraint('CollectionJobTestStatus', { - type: 'unique', - name: 'CollectionJob_Test_unique', - fields: ['collectionJobId', 'testId'], - transaction - }); - }); - }, - - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeConstraint( - 'CollectionJobTestStatus', - 'CollectionJob_Test_unique', - { transaction } - ); - await queryInterface.dropTable('CollectionJobTestStatus', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20240509102300-addIsBot.js b/server/migrations/20240509102300-addIsBot.js deleted file mode 100644 index 5c94c4239..000000000 --- a/server/migrations/20240509102300-addIsBot.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - up: async (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'User', - 'isBot', - { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - }, - { transaction } - ); - await queryInterface.sequelize.query( - `UPDATE "User" SET "isBot" = true WHERE "username" LIKE '% Bot'`, - { transaction } - ); - }); - }, - down: async queryInterface => { - await queryInterface.removeColumn('User', 'isBot'); - } -}; diff --git a/server/migrations/20240516195950-updateMetrics.js b/server/migrations/20240516195950-updateMetrics.js deleted file mode 100644 index f653f7dd2..000000000 --- a/server/migrations/20240516195950-updateMetrics.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -const { getMetrics } = require('shared'); -const populateData = require('../services/PopulatedData/populateData'); -const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); -const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); -const { - updateTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const getGraphQLContext = require('../graphql-context'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanReports = await queryInterface.sequelize.query( - `SELECT id, metrics FROM "TestPlanReport"`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanReport of testPlanReports) { - const { testPlanReport: testPlanReportPopulated } = await populateData( - { testPlanReportId: testPlanReport.id }, - { context } - ); - const runnableTests = runnableTestsResolver( - testPlanReportPopulated, - null, - context - ); - const finalizedTestResults = await finalizedTestResultsResolver( - testPlanReportPopulated, - null, - context - ); - const metrics = getMetrics({ - testPlanReport: { - ...testPlanReportPopulated, - finalizedTestResults, - runnableTests - } - }); - await updateTestPlanReportById({ - id: testPlanReportPopulated.id, - values: { - metrics: { - ...testPlanReportPopulated.metrics, - ...metrics - } - }, - transaction - }); - } - }); - } -}; diff --git a/server/migrations/20240522032230-fixIncorrectDeprecationDates.js b/server/migrations/20240522032230-fixIncorrectDeprecationDates.js deleted file mode 100644 index 502179181..000000000 --- a/server/migrations/20240522032230-fixIncorrectDeprecationDates.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - const SECOND = 1000; - const MINUTE = 60 * SECOND; - - const versionAndRangeCheck = async ( - deprecatedVersion, - maybeDeprecatingVersion, - transaction - ) => { - let relevantPhaseDateFound = false; - let maybeDeprecatingVersionPhaseDate = maybeDeprecatingVersion.updatedAt; - - if (deprecatedVersion.recommendedPhaseReachedAt) { - if (!maybeDeprecatingVersion.recommendedPhaseReachedAt) return; - maybeDeprecatingVersionPhaseDate = - maybeDeprecatingVersion.recommendedPhaseReachedAt; - relevantPhaseDateFound = true; - } - - if ( - deprecatedVersion.candidatePhaseReachedAt && - !relevantPhaseDateFound - ) { - if (!maybeDeprecatingVersion.candidatePhaseReachedAt) return; - maybeDeprecatingVersionPhaseDate = - maybeDeprecatingVersion.candidatePhaseReachedAt; - relevantPhaseDateFound = true; - } - - if (deprecatedVersion.draftPhaseReachedAt && !relevantPhaseDateFound) { - if (!maybeDeprecatingVersion.draftPhaseReachedAt) return; - maybeDeprecatingVersionPhaseDate = - maybeDeprecatingVersion.draftPhaseReachedAt; - } - - // Get a 5-minute range around deprecated version to compare to other - // versions which could have potentially deprecated it based on - // their phase change dates - const deprecatedAtDate = new Date(deprecatedVersion.deprecatedAt); - const startDate = new Date(deprecatedAtDate.getTime() - 5 * MINUTE); - const endDate = new Date(deprecatedAtDate.getTime() + 5 * MINUTE); - - if ( - maybeDeprecatingVersionPhaseDate.getTime() >= startDate.getTime() && - maybeDeprecatingVersionPhaseDate.getTime() <= endDate.getTime() - ) { - // Set updated deprecatedAt date as being 2 seconds before - // whichever dated phase change caused it; exactly how - // updatePhaseResolver and import-tests is done - const updatedDeprecatedAt = new Date( - new Date(maybeDeprecatingVersionPhaseDate.getTime() - 2 * SECOND) - ); - - await queryInterface.sequelize.query( - `update "TestPlanVersion" - set "deprecatedAt" = ? - where id = ? - and "gitSha" = ? - and directory = ?`, - { - replacements: [ - updatedDeprecatedAt, - deprecatedVersion.id, - deprecatedVersion.gitSha, - deprecatedVersion.directory - ], - transaction - } - ); - } - }; - - return queryInterface.sequelize.transaction(async transaction => { - const testPlanVersions = await queryInterface.sequelize.query( - `select "id", - "phase", - "gitSha", - "directory", - "updatedAt", - "draftPhaseReachedAt", - "candidatePhaseReachedAt", - "recommendedPhaseReachedAt", - "deprecatedAt" - from "TestPlanVersion"`, - { type: Sequelize.QueryTypes.SELECT, transaction } - ); - - const deprecatedVersions = testPlanVersions.filter( - ({ phase }) => phase === 'DEPRECATED' - ); - - for (let deprecatedVersion of deprecatedVersions) { - const maybeDeprecatingVersions = testPlanVersions.filter( - ({ id, directory }) => - id !== deprecatedVersion.id && - directory === deprecatedVersion.directory - ); - - for (let maybeDeprecatingVersion of maybeDeprecatingVersions) { - await versionAndRangeCheck( - deprecatedVersion, - maybeDeprecatingVersion, - transaction - ); - } - } - }); - } -}; diff --git a/server/migrations/20240525041559-addCollectionJobSecret.js b/server/migrations/20240525041559-addCollectionJobSecret.js deleted file mode 100644 index a74e9f122..000000000 --- a/server/migrations/20240525041559-addCollectionJobSecret.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const uuid = require('uuid'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.addColumn( - 'CollectionJob', - 'secret', - { - type: Sequelize.DataTypes.UUID, - allowNull: false, - defaultValue: uuid.NIL - }, - { transaction } - ); - }); - }, - async down(queryInterface) { - return queryInterface.sequelize.transaction(async transaction => { - await queryInterface.removeColumn('CollectionJob', 'secret', { - transaction - }); - }); - } -}; diff --git a/server/migrations/20240711160607-update-may-terminology.js b/server/migrations/20240711160607-update-may-terminology.js deleted file mode 100644 index b06922022..000000000 --- a/server/migrations/20240711160607-update-may-terminology.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -/** @type {import('sequelize-cli').Migration} */ -const updateMetricsTerminology = async ( - queryInterface, - Sequelize, - oldTerm, - newTerm -) => { - const [reports] = await queryInterface.sequelize.query( - 'SELECT id, metrics FROM "TestPlanReport";' - ); - - const updatePromises = reports.map(report => { - const { metrics } = report; - - if (metrics.mayFormatted) { - metrics.mayFormatted = metrics.mayFormatted.replace(oldTerm, newTerm); - } - - return queryInterface.sequelize.query( - 'UPDATE "TestPlanReport" SET metrics = :metrics WHERE id = :id', - { - replacements: { - metrics: JSON.stringify(metrics), - id: report.id - }, - type: Sequelize.QueryTypes.UPDATE - } - ); - }); - - await Promise.all(updatePromises); -}; - -module.exports = { - up: async (queryInterface, Sequelize) => { - await updateMetricsTerminology( - queryInterface, - Sequelize, - 'passed', - 'supported' - ); - }, - - down: async (queryInterface, Sequelize) => { - await updateMetricsTerminology( - queryInterface, - Sequelize, - 'supported', - 'passed' - ); - } -}; diff --git a/server/migrations/20240715150459-resetTestPlanVersionIdToLatest.js b/server/migrations/20240715150459-resetTestPlanVersionIdToLatest.js deleted file mode 100644 index b0e59a0b3..000000000 --- a/server/migrations/20240715150459-resetTestPlanVersionIdToLatest.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const { sequelize } = require('../models'); -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const [latestTestPlanVersion] = await queryInterface.sequelize.query( - `select id - from "TestPlanVersion" - order by id desc - limit 1`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - if (latestTestPlanVersion) { - await sequelize.query( - `SELECT setval(pg_get_serial_sequence('"TestPlanVersion"', 'id'), :currentSequenceValue)`, - { - replacements: { currentSequenceValue: latestTestPlanVersion.id }, - transaction - } - ); - } - }); - }, - - async down() {} -}; diff --git a/server/migrations/20240724212706-updateMetrics.js b/server/migrations/20240724212706-updateMetrics.js deleted file mode 100644 index 008c4482f..000000000 --- a/server/migrations/20240724212706-updateMetrics.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -const { getMetrics } = require('shared'); -const populateData = require('../services/PopulatedData/populateData'); -const runnableTestsResolver = require('../resolvers/TestPlanReport/runnableTestsResolver'); -const finalizedTestResultsResolver = require('../resolvers/TestPlanReport/finalizedTestResultsResolver'); -const { - updateTestPlanReportById -} = require('../models/services/TestPlanReportService'); -const getGraphQLContext = require('../graphql-context'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - return queryInterface.sequelize.transaction(async transaction => { - const context = getGraphQLContext({ req: { transaction } }); - - const testPlanReports = await queryInterface.sequelize.query( - `select distinct on ("TestPlanReport".id) "TestPlanReport".id, metrics - from "TestPlanReport" - join public."TestPlanRun" testPlanRun on "TestPlanReport".id = testPlanRun."testPlanReportId" - where jsonb_array_length(testPlanRun."testResults") > 0;`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const testPlanReport of testPlanReports) { - const { testPlanReport: testPlanReportPopulated } = await populateData( - { testPlanReportId: testPlanReport.id }, - { context } - ); - const runnableTests = runnableTestsResolver( - testPlanReportPopulated, - null, - context - ); - const finalizedTestResults = await finalizedTestResultsResolver( - testPlanReportPopulated, - null, - context - ); - const metrics = getMetrics({ - testPlanReport: { - ...testPlanReportPopulated, - finalizedTestResults, - runnableTests - } - }); - await updateTestPlanReportById({ - id: testPlanReportPopulated.id, - values: { - metrics: { - ...testPlanReportPopulated.metrics, - ...metrics - } - }, - transaction - }); - } - }); - } -}; From 018122814d99e977e040bd5aaef57988db732379 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 09:15:17 -0400 Subject: [PATCH 02/10] Update migrations/utils --- server/migrations/utils/index.js | 235 +----------------- server/migrations/utils/recalculateMetrics.js | 64 +++++ .../regenerateResultsAndRecalculateHashes.js | 234 +++++++++++++++++ 3 files changed, 301 insertions(+), 232 deletions(-) create mode 100644 server/migrations/utils/recalculateMetrics.js create mode 100644 server/migrations/utils/regenerateResultsAndRecalculateHashes.js diff --git a/server/migrations/utils/index.js b/server/migrations/utils/index.js index 0975a5249..7e3bf3160 100644 --- a/server/migrations/utils/index.js +++ b/server/migrations/utils/index.js @@ -1,236 +1,7 @@ -const { Sequelize } = require('sequelize'); -const { - createTestResultId, - createScenarioResultId, - createAssertionResultId -} = require('../../services/PopulatedData/locationOfDataId'); -const { hashTests } = require('../../util/aria'); - -/** - * Recompute TestPlanVersion.hashedTests - * @param queryInterface - The Sequelize.QueryInterface object. - * @param transaction - The Sequelize.Transaction object. - * @param testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed - * @param pruneOldVersions - Force removal of TestPlanVersions with conflicting hashes after regenerating - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise} - */ -const computeTestPlanVersionHashedTests = async ( - queryInterface, - transaction, - testPlanVersionWhere, - pruneOldVersions -) => { - const results = await queryInterface.sequelize.query( - `SELECT COUNT(*) FROM "TestPlanVersion" ${testPlanVersionWhere}`, - { transaction } - ); - const [[{ count: testPlanVersionCount }]] = results; - - const testPlanVersionBatchSize = 10; - const iterationsNeeded = Math.ceil( - testPlanVersionCount / testPlanVersionBatchSize - ); - - const knownHashedTests = []; - for (let i = 0; i < iterationsNeeded; i += 1) { - const multipleOf100 = i % testPlanVersionBatchSize === 0; - if (multipleOf100) - // eslint-disable-next-line no-console - console.info( - 'Indexing TestPlanVersions', - i * testPlanVersionBatchSize, - 'of', - Number(testPlanVersionCount) - ); - const currentOffset = i * testPlanVersionBatchSize; - - const [testPlanVersions] = await queryInterface.sequelize.query( - `SELECT id, directory, "gitSha", tests, "updatedAt" FROM "TestPlanVersion" ${testPlanVersionWhere} ORDER BY id LIMIT ? OFFSET ?`, - { - replacements: [testPlanVersionBatchSize, currentOffset], - transaction - } - ); - - await Promise.all( - testPlanVersions.map(async testPlanVersion => { - const hashedTests = hashTests(testPlanVersion.tests); - - if (!knownHashedTests.includes(hashedTests)) { - knownHashedTests.push(hashedTests); - await queryInterface.sequelize.query( - `UPDATE "TestPlanVersion" SET "hashedTests" = ? WHERE id = ?`, - { - replacements: [hashedTests, testPlanVersion.id], - transaction - } - ); - } else if (pruneOldVersions) { - // Remove any accidentally created TestPlanVersion rows created prior to migration - await queryInterface.sequelize.query( - `DELETE FROM "TestPlanVersion" WHERE id = ?`, - { - replacements: [testPlanVersion.id], - transaction - } - ); - } - }) - ); - } -}; - -/** - * Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults, for - * TestRuns - * @param queryInterface - The Sequelize.QueryInterface object. - * @param transaction - The Sequelize.Transaction object. - * @param testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise} - */ -const regenerateExistingTestResults = async ( - queryInterface, - transaction, - testPlanVersionWhere -) => { - const testPlanVersions = await queryInterface.sequelize.query( - `SELECT id, tests FROM "TestPlanVersion" ${testPlanVersionWhere}`, - { - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - if (testPlanVersions.length) { - const testPlanReports = await queryInterface.sequelize.query( - `select id, "testPlanVersionId" - from "TestPlanReport" - where "testPlanVersionId" in (?)`, - { - replacements: [testPlanVersions.map(e => e.id)], - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const key in testPlanReports) { - const { id: testPlanReportId } = testPlanReports[key]; - - const testPlanRuns = await queryInterface.sequelize.query( - `select testPlanRun.id, "testPlanReportId", "atId", "testPlanVersionId", "testResults", tests - from "TestPlanRun" testPlanRun - join "TestPlanReport" testPlanReport - on testPlanReport.id = testPlanRun."testPlanReportId" - join "TestPlanVersion" testPlanVersion - on testPlanVersion.id = testPlanReport."testPlanVersionId" - where "testPlanReportId" = ?`, - { - replacements: [testPlanReportId], - type: Sequelize.QueryTypes.SELECT, - transaction - } - ); - - for (const key in testPlanRuns) { - const { - id: testPlanRunId, - atId, - testResults, - tests - } = testPlanRuns[key]; - - tests.forEach(test => { - const testId = test.id; - - testResults.forEach(testResult => { - if (testResult.testId === testId) { - // Update testResult.id - const testResultId = createTestResultId( - testPlanRunId, - testResult.testId - ); - testResult.id = testResultId; - - // The sub-arrays should be in the same order - testResult.scenarioResults.forEach( - (eachScenarioResult, scenarioIndex) => { - eachScenarioResult.scenarioId = test.scenarios.filter( - scenario => scenario.atId === atId - )[scenarioIndex].id; - - // Update eachScenarioResult.id - const scenarioResultId = createScenarioResultId( - testResultId, - eachScenarioResult.scenarioId - ); - eachScenarioResult.id = scenarioResultId; - - eachScenarioResult.assertionResults.forEach( - (eachAssertionResult, assertionIndex) => { - eachAssertionResult.assertionId = - test.assertions[assertionIndex].id; - - // Update eachAssertionResult.id - eachAssertionResult.id = createAssertionResultId( - scenarioResultId, - eachAssertionResult.assertionId - ); - } - ); - } - ); - } - }); - }); - - await queryInterface.sequelize.query( - `update "TestPlanRun" - set "testResults" = ? - where id = ?`, - { - replacements: [JSON.stringify(testResults), testPlanRunId], - transaction - } - ); - // eslint-disable-next-line no-console - console.info('Fixing testResults for TestPlanRun', testPlanRunId); - } - } - } -}; - -/** - * Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults, for - * TestRuns and regenerates TestPlanVersion.hashedTests if required - * @param queryInterface - The Sequelize.QueryInterface object. - * @param transaction - The Sequelize.Transaction object. - * @param options - Additional options to use when performing function - * @param options.testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed - * @param options.pruneOldVersions - Force removal of TestPlanVersions with conflicting hashes after regenerating - * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} - * @returns {Promise} - */ -const regenerateResultsAndRecalculateHashes = async ( - queryInterface, - transaction, - { testPlanVersionWhere = '', pruneOldVersions = true } = {} -) => { - await computeTestPlanVersionHashedTests( - queryInterface, - transaction, - testPlanVersionWhere, - pruneOldVersions - ); - - await regenerateExistingTestResults( - queryInterface, - transaction, - testPlanVersionWhere - ); -}; +const recalculateMetrics = require('./recalculateMetrics'); +const regenerateResultsAndRecalculateHashes = require('./regenerateResultsAndRecalculateHashes'); module.exports = { + recalculateMetrics, regenerateResultsAndRecalculateHashes }; diff --git a/server/migrations/utils/recalculateMetrics.js b/server/migrations/utils/recalculateMetrics.js new file mode 100644 index 000000000..7267f3e67 --- /dev/null +++ b/server/migrations/utils/recalculateMetrics.js @@ -0,0 +1,64 @@ +const { Sequelize } = require('sequelize'); +const getGraphQLContext = require('../../graphql-context'); +const populateData = require('../../services/PopulatedData/populateData'); +const runnableTestsResolver = require('../../resolvers/TestPlanReport/runnableTestsResolver'); +const finalizedTestResultsResolver = require('../../resolvers/TestPlanReport/finalizedTestResultsResolver'); +const { getMetrics } = require('shared'); +const { + updateTestPlanReportById +} = require('../../models/services/TestPlanReportService'); + +/** + * Recalculate TestPlanReport.metrics + * @param queryInterface - The Sequelize.QueryInterface object. + * @param transaction - The Sequelize.Transaction object. + * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} + * @returns {Promise} + */ +const recalculateMetrics = async (queryInterface, transaction) => { + const context = getGraphQLContext({ req: { transaction } }); + + const testPlanReports = await queryInterface.sequelize.query( + `SELECT id, metrics FROM "TestPlanReport"`, + { + type: Sequelize.QueryTypes.SELECT, + transaction + } + ); + + for (const testPlanReport of testPlanReports) { + const { testPlanReport: testPlanReportPopulated } = await populateData( + { testPlanReportId: testPlanReport.id }, + { context } + ); + const runnableTests = runnableTestsResolver( + testPlanReportPopulated, + null, + context + ); + const finalizedTestResults = await finalizedTestResultsResolver( + testPlanReportPopulated, + null, + context + ); + const metrics = getMetrics({ + testPlanReport: { + ...testPlanReportPopulated, + finalizedTestResults, + runnableTests + } + }); + await updateTestPlanReportById({ + id: testPlanReportPopulated.id, + values: { + metrics: { + ...testPlanReportPopulated.metrics, + ...metrics + } + }, + transaction + }); + } +}; + +module.exports = recalculateMetrics; diff --git a/server/migrations/utils/regenerateResultsAndRecalculateHashes.js b/server/migrations/utils/regenerateResultsAndRecalculateHashes.js new file mode 100644 index 000000000..9ffc2ebdf --- /dev/null +++ b/server/migrations/utils/regenerateResultsAndRecalculateHashes.js @@ -0,0 +1,234 @@ +const { Sequelize } = require('sequelize'); +const { + createTestResultId, + createScenarioResultId, + createAssertionResultId +} = require('../../services/PopulatedData/locationOfDataId'); +const { hashTests } = require('../../util/aria'); + +/** + * Recompute TestPlanVersion.hashedTests + * @param queryInterface - The Sequelize.QueryInterface object. + * @param transaction - The Sequelize.Transaction object. + * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} + * @param testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed + * @param pruneOldVersions - Force removal of TestPlanVersions with conflicting hashes after regenerating + * @returns {Promise} + */ +const computeTestPlanVersionHashedTests = async ( + queryInterface, + transaction, + testPlanVersionWhere, + pruneOldVersions +) => { + const results = await queryInterface.sequelize.query( + `SELECT COUNT(*) FROM "TestPlanVersion" ${testPlanVersionWhere}`, + { transaction } + ); + const [[{ count: testPlanVersionCount }]] = results; + + const testPlanVersionBatchSize = 10; + const iterationsNeeded = Math.ceil( + testPlanVersionCount / testPlanVersionBatchSize + ); + + const knownHashedTests = []; + for (let i = 0; i < iterationsNeeded; i += 1) { + const multipleOf100 = i % testPlanVersionBatchSize === 0; + if (multipleOf100) + // eslint-disable-next-line no-console + console.info( + 'Indexing TestPlanVersions', + i * testPlanVersionBatchSize, + 'of', + Number(testPlanVersionCount) + ); + const currentOffset = i * testPlanVersionBatchSize; + + const [testPlanVersions] = await queryInterface.sequelize.query( + `SELECT id, directory, "gitSha", tests, "updatedAt" FROM "TestPlanVersion" ${testPlanVersionWhere} ORDER BY id LIMIT ? OFFSET ?`, + { + replacements: [testPlanVersionBatchSize, currentOffset], + transaction + } + ); + + await Promise.all( + testPlanVersions.map(async testPlanVersion => { + const hashedTests = hashTests(testPlanVersion.tests); + + if (!knownHashedTests.includes(hashedTests)) { + knownHashedTests.push(hashedTests); + await queryInterface.sequelize.query( + `UPDATE "TestPlanVersion" SET "hashedTests" = ? WHERE id = ?`, + { + replacements: [hashedTests, testPlanVersion.id], + transaction + } + ); + } else if (pruneOldVersions) { + // Remove any accidentally created TestPlanVersion rows created prior to migration + await queryInterface.sequelize.query( + `DELETE FROM "TestPlanVersion" WHERE id = ?`, + { + replacements: [testPlanVersion.id], + transaction + } + ); + } + }) + ); + } +}; + +/** + * Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults, for + * TestRuns + * @param queryInterface - The Sequelize.QueryInterface object. + * @param transaction - The Sequelize.Transaction object. + * @param testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed + * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} + * @returns {Promise} + */ +const regenerateExistingTestResults = async ( + queryInterface, + transaction, + testPlanVersionWhere +) => { + const testPlanVersions = await queryInterface.sequelize.query( + `SELECT id, tests FROM "TestPlanVersion" ${testPlanVersionWhere}`, + { + type: Sequelize.QueryTypes.SELECT, + transaction + } + ); + + if (testPlanVersions.length) { + const testPlanReports = await queryInterface.sequelize.query( + `select id, "testPlanVersionId" + from "TestPlanReport" + where "testPlanVersionId" in (?)`, + { + replacements: [testPlanVersions.map(e => e.id)], + type: Sequelize.QueryTypes.SELECT, + transaction + } + ); + + for (const key in testPlanReports) { + const { id: testPlanReportId } = testPlanReports[key]; + + const testPlanRuns = await queryInterface.sequelize.query( + `select testPlanRun.id, "testPlanReportId", "atId", "testPlanVersionId", "testResults", tests + from "TestPlanRun" testPlanRun + join "TestPlanReport" testPlanReport + on testPlanReport.id = testPlanRun."testPlanReportId" + join "TestPlanVersion" testPlanVersion + on testPlanVersion.id = testPlanReport."testPlanVersionId" + where "testPlanReportId" = ?`, + { + replacements: [testPlanReportId], + type: Sequelize.QueryTypes.SELECT, + transaction + } + ); + + for (const key in testPlanRuns) { + const { + id: testPlanRunId, + atId, + testResults, + tests + } = testPlanRuns[key]; + + tests.forEach(test => { + const testId = test.id; + + testResults.forEach(testResult => { + if (testResult.testId === testId) { + // Update testResult.id + const testResultId = createTestResultId( + testPlanRunId, + testResult.testId + ); + testResult.id = testResultId; + + // The sub-arrays should be in the same order + testResult.scenarioResults.forEach( + (eachScenarioResult, scenarioIndex) => { + eachScenarioResult.scenarioId = test.scenarios.filter( + scenario => scenario.atId === atId + )[scenarioIndex].id; + + // Update eachScenarioResult.id + const scenarioResultId = createScenarioResultId( + testResultId, + eachScenarioResult.scenarioId + ); + eachScenarioResult.id = scenarioResultId; + + eachScenarioResult.assertionResults.forEach( + (eachAssertionResult, assertionIndex) => { + eachAssertionResult.assertionId = + test.assertions[assertionIndex].id; + + // Update eachAssertionResult.id + eachAssertionResult.id = createAssertionResultId( + scenarioResultId, + eachAssertionResult.assertionId + ); + } + ); + } + ); + } + }); + }); + + await queryInterface.sequelize.query( + `update "TestPlanRun" + set "testResults" = ? + where id = ?`, + { + replacements: [JSON.stringify(testResults), testPlanRunId], + transaction + } + ); + // eslint-disable-next-line no-console + console.info('Fixing testResults for TestPlanRun', testPlanRunId); + } + } + } +}; + +/** + * Regenerate the testIds, scenarioIds and assertionsIds in TestRun.testResults, for + * TestRuns and regenerates TestPlanVersion.hashedTests if required + * @param queryInterface - The Sequelize.QueryInterface object. + * @param transaction - The Sequelize.Transaction object. + * @param options - Additional options to use when performing function + * @param options.testPlanVersionWhere - Additional WHERE clauses when querying TestPlanVersion if needed + * @param options.pruneOldVersions - Force removal of TestPlanVersions with conflicting hashes after regenerating + * See {@https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-method-transaction} + * @returns {Promise} + */ +const regenerateResultsAndRecalculateHashes = async ( + queryInterface, + transaction, + { testPlanVersionWhere = '', pruneOldVersions = true } = {} +) => { + await computeTestPlanVersionHashedTests( + queryInterface, + transaction, + testPlanVersionWhere, + pruneOldVersions + ); + + await regenerateExistingTestResults( + queryInterface, + transaction, + testPlanVersionWhere + ); +}; + +module.exports = regenerateResultsAndRecalculateHashes; From 590833916ea8c5a3a6c1ec5d0f01c4bd4072c3a0 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 09:15:30 -0400 Subject: [PATCH 03/10] Add flattened migration --- ...0710212012-flattenMigrationsPre20240710.js | 25 + server/migrations/pg_dump_20240710.sql | 1156 +++++++++++++++++ 2 files changed, 1181 insertions(+) create mode 100644 server/migrations/20240710212012-flattenMigrationsPre20240710.js create mode 100644 server/migrations/pg_dump_20240710.sql diff --git a/server/migrations/20240710212012-flattenMigrationsPre20240710.js b/server/migrations/20240710212012-flattenMigrationsPre20240710.js new file mode 100644 index 000000000..9332fbee9 --- /dev/null +++ b/server/migrations/20240710212012-flattenMigrationsPre20240710.js @@ -0,0 +1,25 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + const sqlFilePath = path.join(__dirname, 'pg_dump_20240710.sql'); + const sql = fs.readFileSync(sqlFilePath, 'utf-8'); + + return queryInterface.sequelize.query(sql); + + // return queryInterface.sequelize.transaction(() => { + // return Promise.all([ + // Promise.resolve() + // .then(() => + // fs.readFileSync(__dirname + '/pg_dump_20240710.sql', 'utf-8') + // ) + // .then(sql => queryInterface.sequelize.query(sql)) + // ]); + // }); + }, + async down() {} +}; diff --git a/server/migrations/pg_dump_20240710.sql b/server/migrations/pg_dump_20240710.sql new file mode 100644 index 000000000..d90d58234 --- /dev/null +++ b/server/migrations/pg_dump_20240710.sql @@ -0,0 +1,1156 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 14.12 (Homebrew) +-- Dumped by pg_dump version 14.12 (Homebrew) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: At; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."At" ( + id integer NOT NULL, + name text NOT NULL, + key text +); + + +ALTER TABLE public."At" OWNER TO atr; + +-- +-- Name: AtBrowsers; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."AtBrowsers" ( + "atId" integer NOT NULL, + "browserId" integer NOT NULL, + "isCandidate" boolean NOT NULL, + "isRecommended" boolean NOT NULL +); + + +ALTER TABLE public."AtBrowsers" OWNER TO atr; + +-- +-- Name: AtVersion; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."AtVersion" ( + "atId" integer NOT NULL, + name text NOT NULL, + id integer NOT NULL, + "releasedAt" timestamp with time zone DEFAULT '2024-07-29 11:43:34.459-04'::timestamp with time zone NOT NULL +); + + +ALTER TABLE public."AtVersion" OWNER TO atr; + +-- +-- Name: AtVersion_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."AtVersion_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."AtVersion_id_seq" OWNER TO atr; + +-- +-- Name: AtVersion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."AtVersion_id_seq" OWNED BY public."AtVersion".id; + + +-- +-- Name: At_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."At_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."At_id_seq" OWNER TO atr; + +-- +-- Name: At_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."At_id_seq" OWNED BY public."At".id; + + +-- +-- Name: Browser; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."Browser" ( + id integer NOT NULL, + name text NOT NULL, + key text +); + + +ALTER TABLE public."Browser" OWNER TO atr; + +-- +-- Name: BrowserVersion; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."BrowserVersion" ( + "browserId" integer NOT NULL, + name text NOT NULL, + id integer NOT NULL, + "releasedAt" timestamp with time zone +); + + +ALTER TABLE public."BrowserVersion" OWNER TO atr; + +-- +-- Name: BrowserVersion_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."BrowserVersion_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."BrowserVersion_id_seq" OWNER TO atr; + +-- +-- Name: BrowserVersion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."BrowserVersion_id_seq" OWNED BY public."BrowserVersion".id; + + +-- +-- Name: Browser_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."Browser_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."Browser_id_seq" OWNER TO atr; + +-- +-- Name: Browser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."Browser_id_seq" OWNED BY public."Browser".id; + + +-- +-- Name: CollectionJob; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."CollectionJob" ( + id integer NOT NULL, + status character varying(255) DEFAULT 'QUEUED'::character varying NOT NULL, + "externalLogsUrl" character varying(255) DEFAULT NULL::character varying, + "testPlanRunId" integer, + secret uuid DEFAULT '00000000-0000-0000-0000-000000000000'::uuid NOT NULL +); + + +ALTER TABLE public."CollectionJob" OWNER TO atr; + +-- +-- Name: CollectionJobTestStatus; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."CollectionJobTestStatus" ( + id integer NOT NULL, + "testId" character varying(255) NOT NULL, + "collectionJobId" integer NOT NULL, + status character varying(255) DEFAULT 'QUEUED'::character varying NOT NULL +); + + +ALTER TABLE public."CollectionJobTestStatus" OWNER TO atr; + +-- +-- Name: CollectionJobTestStatus_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."CollectionJobTestStatus_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."CollectionJobTestStatus_id_seq" OWNER TO atr; + +-- +-- Name: CollectionJobTestStatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."CollectionJobTestStatus_id_seq" OWNED BY public."CollectionJobTestStatus".id; + + +-- +-- Name: Role; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."Role" ( + name text NOT NULL +); + + +ALTER TABLE public."Role" OWNER TO atr; + +-- +-- Name: SequelizeMeta; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."SequelizeMeta" ( + name character varying(255) NOT NULL +); + + +ALTER TABLE public."SequelizeMeta" OWNER TO atr; + +-- +-- Name: TestPlan; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."TestPlan" ( + id integer NOT NULL, + title text, + directory text +); + + +ALTER TABLE public."TestPlan" OWNER TO atr; + +-- +-- Name: TestPlanReport; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."TestPlanReport" ( + id integer NOT NULL, + "testPlanVersionId" integer, + "createdAt" timestamp with time zone, + "atId" integer, + "browserId" integer, + "markedFinalAt" timestamp with time zone, + "vendorReviewStatus" text, + metrics jsonb DEFAULT '{}'::jsonb NOT NULL, + "testPlanId" integer, + "exactAtVersionId" integer, + "minimumAtVersionId" integer +); + + +ALTER TABLE public."TestPlanReport" OWNER TO atr; + +-- +-- Name: TestPlanReport_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."TestPlanReport_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."TestPlanReport_id_seq" OWNER TO atr; + +-- +-- Name: TestPlanReport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."TestPlanReport_id_seq" OWNED BY public."TestPlanReport".id; + + +-- +-- Name: TestPlanRun; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."TestPlanRun" ( + id integer NOT NULL, + "testerUserId" integer, + "testPlanReportId" integer, + "testResults" jsonb DEFAULT '[]'::jsonb, + "initiatedByAutomation" boolean DEFAULT false NOT NULL, + "isPrimary" boolean DEFAULT false +); + + +ALTER TABLE public."TestPlanRun" OWNER TO atr; + +-- +-- Name: TestPlanRun_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."TestPlanRun_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."TestPlanRun_id_seq" OWNER TO atr; + +-- +-- Name: TestPlanRun_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."TestPlanRun_id_seq" OWNED BY public."TestPlanRun".id; + + +-- +-- Name: TestPlanVersion; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."TestPlanVersion" ( + id integer NOT NULL, + title text, + "gitSha" text, + "gitMessage" text, + "testPageUrl" text, + "updatedAt" timestamp with time zone, + tests jsonb DEFAULT '[]'::jsonb, + metadata jsonb, + directory text, + "testPlanId" integer, + "hashedTests" text NOT NULL, + phase text DEFAULT 'RD'::text NOT NULL, + "draftPhaseReachedAt" timestamp with time zone, + "candidatePhaseReachedAt" timestamp with time zone, + "recommendedPhaseReachedAt" timestamp with time zone, + "recommendedPhaseTargetDate" timestamp with time zone, + "deprecatedAt" timestamp with time zone, + "versionString" text NOT NULL +); + + +ALTER TABLE public."TestPlanVersion" OWNER TO atr; + +-- +-- Name: TestPlan_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."TestPlan_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."TestPlan_id_seq" OWNER TO atr; + +-- +-- Name: TestPlan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."TestPlan_id_seq" OWNED BY public."TestPlanVersion".id; + + +-- +-- Name: TestPlan_id_seq1; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."TestPlan_id_seq1" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."TestPlan_id_seq1" OWNER TO atr; + +-- +-- Name: TestPlan_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."TestPlan_id_seq1" OWNED BY public."TestPlan".id; + + +-- +-- Name: User; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."User" ( + id integer NOT NULL, + username text NOT NULL, + "createdAt" timestamp with time zone, + "updatedAt" timestamp with time zone, + "isBot" boolean DEFAULT false NOT NULL +); + + +ALTER TABLE public."User" OWNER TO atr; + +-- +-- Name: UserAts; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."UserAts" ( + "userId" integer, + "atId" integer +); + + +ALTER TABLE public."UserAts" OWNER TO atr; + +-- +-- Name: UserRoles; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public."UserRoles" ( + "userId" integer NOT NULL, + "roleName" text NOT NULL +); + + +ALTER TABLE public."UserRoles" OWNER TO atr; + +-- +-- Name: User_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public."User_id_seq" + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public."User_id_seq" OWNER TO atr; + +-- +-- Name: User_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public."User_id_seq" OWNED BY public."User".id; + + +-- +-- Name: collectionjob_id_seq; Type: SEQUENCE; Schema: public; Owner: atr +-- + +CREATE SEQUENCE IF NOT EXISTS public.collectionjob_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.collectionjob_id_seq OWNER TO atr; + +-- +-- Name: collectionjob_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr +-- + +ALTER SEQUENCE public.collectionjob_id_seq OWNED BY public."CollectionJob".id; + + +-- +-- Name: session; Type: TABLE; Schema: public; Owner: atr +-- + +CREATE TABLE IF NOT EXISTS public.session ( + sid character varying NOT NULL, + sess jsonb NOT NULL, + expire timestamp(6) without time zone NOT NULL +); + + +ALTER TABLE public.session OWNER TO atr; + +-- +-- Name: At id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."At" ALTER COLUMN id SET DEFAULT nextval('public."At_id_seq"'::regclass); + + +-- +-- Name: AtVersion id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."AtVersion" ALTER COLUMN id SET DEFAULT nextval('public."AtVersion_id_seq"'::regclass); + + +-- +-- Name: Browser id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."Browser" ALTER COLUMN id SET DEFAULT nextval('public."Browser_id_seq"'::regclass); + + +-- +-- Name: BrowserVersion id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."BrowserVersion" ALTER COLUMN id SET DEFAULT nextval('public."BrowserVersion_id_seq"'::regclass); + + +-- +-- Name: CollectionJob id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."CollectionJob" ALTER COLUMN id SET DEFAULT nextval('public.collectionjob_id_seq'::regclass); + + +-- +-- Name: CollectionJobTestStatus id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."CollectionJobTestStatus" ALTER COLUMN id SET DEFAULT nextval('public."CollectionJobTestStatus_id_seq"'::regclass); + + +-- +-- Name: TestPlan id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."TestPlan" ALTER COLUMN id SET DEFAULT nextval('public."TestPlan_id_seq1"'::regclass); + + +-- +-- Name: TestPlanReport id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."TestPlanReport" ALTER COLUMN id SET DEFAULT nextval('public."TestPlanReport_id_seq"'::regclass); + + +-- +-- Name: TestPlanRun id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."TestPlanRun" ALTER COLUMN id SET DEFAULT nextval('public."TestPlanRun_id_seq"'::regclass); + + +-- +-- Name: TestPlanVersion id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."TestPlanVersion" ALTER COLUMN id SET DEFAULT nextval('public."TestPlan_id_seq"'::regclass); + + +-- +-- Name: User id; Type: DEFAULT; Schema: public; Owner: atr +-- + +ALTER TABLE ONLY public."User" ALTER COLUMN id SET DEFAULT nextval('public."User_id_seq"'::regclass); + + +-- +-- Data for Name: At; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: AtBrowsers; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: AtVersion; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: Browser; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: BrowserVersion; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: CollectionJob; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: CollectionJobTestStatus; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: Role; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: SequelizeMeta; Type: TABLE DATA; Schema: public; Owner: atr +-- + +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200518185559-initial-migration.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200521003201-create_table_test_issues.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200522002555-add-serialized-form-column-to-test-results.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528143617-add-run-status.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528143624-add-run-status-to-run.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528172804-add-run-status-to-run-data-view.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915181019-create-browser-version-to-at-and-at-version.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915184800-AddActiveFlags.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915203422-AddColumnsToTestRun.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200928035513-update-create-browser-version-to-at-version.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20200929194042-AddActiveToTestVersions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20201016203157-RemoveTestCycleModel.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20201201232332-add-links-columns-apg-examples.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210512004505-BuildNewDatabaseSchema.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210524210332-TestQueueChanges.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152335-supportNewTestQueueMutations.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152340-emptyObsoleteTables.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152341-removeTestPlanTargetVersionConstraints.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210809220722-UserSettings.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20210920195544-reportingBackend.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20211116172219-commandSequences.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20211118143508-testRowNumber.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427145338-alterAtVersionTable.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427192638-changeConstraintsAtVersion.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427194229-addIdConstraintAtVersion.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427204420-changeAtVersionColumn.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220503193406-alterBrowserVersionTable.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220509140537-removeTestPlanTarget.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220712044433-changeJsonbArraysToJsonb.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220801210224-updateJawsTestInstructions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220825125643-addStatusChangeUpdateColumns.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220919142951-addVendorReviewStatusColumn.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220928162616-addViewersToTests.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220929155024-addMetricsColumn.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20220929155029-addMetricsValues.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20221116154332-updateTestPlanReportStatuses.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230329214527-removeInReviewStatusFromTestPlanReport.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230424152008-addAtBrowser.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230424152008-createTestPlanTable.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230425152008-createTestPlanColumns.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230425215656-updateTestPlanVersionTitles.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230501220810-deduplicateTestPlanVersions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230523163855-addColumnsToAtBrowsers.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230523163856-remove-OtherUnexpectedBehaviorText.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230608170853-addDateColumnsToTestPlanVersion.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230719174358-removeTestPlanReportStatus.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230823212533-addCollectionJobs.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230927172432-addVersionStrings.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20230927230957-add-initiatedByAutomation-to-testPlanRun.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20231031162340-verifyNoSkippedTests.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20231114170315-addScreenTextAndInstructionsToAtMode.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20231219212344-recalculateV2TestHashes.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240104150500-includeAdditionalTestFormatVersionAttributes.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240111225130-includeMissingAssertionExceptions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240215220201-updateMetricsForCountingUnexpectedBehaviors.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240224173914-includeAssertionIdInTestAssertions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240229195433-modifyCollectionJobIdType.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240305205951-removeAtMode.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240311192910-removeRequiredAndOptionalPriority.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312122457-testPlanReportAtVersions.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312131258-browserVersionReleasedAt.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312145416-updateMetricsForUsingTotalCalculation.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240313145124-addIsPrimaryColumnToTestPlanRun.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240319190618-updateCandidatePhaseReachedDates.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240321182449-addKeyColumnToAtAndBrowserTables.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240325205951-cleanupDuplicatesAndRegenerateHashes.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240401203810-fixCommandButtonPhaseChangeDate.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240404171101-addCollectionJobTestStatus.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240509102300-addIsBot.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240516195950-updateMetrics.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240522032230-fixIncorrectDeprecationDates.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240525041559-addCollectionJobSecret.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240711160607-update-may-terminology.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240715150459-resetTestPlanVersionIdToLatest.js') ON CONFLICT DO NOTHING; +INSERT INTO public."SequelizeMeta" (name) VALUES ('20240724212706-updateMetrics.js') ON CONFLICT DO NOTHING; + + +-- +-- Data for Name: TestPlan; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: TestPlanReport; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: TestPlanRun; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: TestPlanVersion; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: User; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: UserAts; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: UserRoles; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Data for Name: session; Type: TABLE DATA; Schema: public; Owner: atr +-- + + + +-- +-- Name: AtVersion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."AtVersion_id_seq"', 1, false); + + +-- +-- Name: At_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."At_id_seq"', 1, false); + + +-- +-- Name: BrowserVersion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."BrowserVersion_id_seq"', 1, false); + + +-- +-- Name: Browser_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."Browser_id_seq"', 1, false); + + +-- +-- Name: CollectionJobTestStatus_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."CollectionJobTestStatus_id_seq"', 1, false); + + +-- +-- Name: TestPlanReport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."TestPlanReport_id_seq"', 1, false); + + +-- +-- Name: TestPlanRun_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."TestPlanRun_id_seq"', 1, false); + + +-- +-- Name: TestPlan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."TestPlan_id_seq"', 1, false); + + +-- +-- Name: TestPlan_id_seq1; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."TestPlan_id_seq1"', 1, false); + + +-- +-- Name: User_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public."User_id_seq"', 1, false); + + +-- +-- Name: collectionjob_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr +-- + +SELECT pg_catalog.setval('public.collectionjob_id_seq', 1, true); + + +-- +-- Name: AtVersion AtVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_pkey" CASCADE; +ALTER TABLE ONLY public."AtVersion" + ADD CONSTRAINT "AtVersion_pkey" PRIMARY KEY (id); + + +-- +-- Name: At At_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."At" DROP CONSTRAINT IF EXISTS "At_pkey" CASCADE; +ALTER TABLE ONLY public."At" + ADD CONSTRAINT "At_pkey" PRIMARY KEY (id); + + +-- +-- Name: BrowserVersion BrowserVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_pkey" CASCADE; +ALTER TABLE ONLY public."BrowserVersion" + ADD CONSTRAINT "BrowserVersion_pkey" PRIMARY KEY (id); + + +-- +-- Name: Browser Browser_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."Browser" DROP CONSTRAINT IF EXISTS "Browser_pkey" CASCADE; +ALTER TABLE ONLY public."Browser" + ADD CONSTRAINT "Browser_pkey" PRIMARY KEY (id); + + +-- +-- Name: CollectionJobTestStatus CollectionJobTestStatus_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJobTestStatus_pkey" CASCADE; +ALTER TABLE ONLY public."CollectionJobTestStatus" + ADD CONSTRAINT "CollectionJobTestStatus_pkey" PRIMARY KEY (id); + + +-- +-- Name: CollectionJobTestStatus CollectionJob_Test_unique; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJob_Test_unique" CASCADE; +ALTER TABLE ONLY public."CollectionJobTestStatus" + ADD CONSTRAINT "CollectionJob_Test_unique" UNIQUE ("collectionJobId", "testId"); + + +-- +-- Name: CollectionJob CollectionJob_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_pkey" CASCADE; +ALTER TABLE ONLY public."CollectionJob" + ADD CONSTRAINT "CollectionJob_pkey" PRIMARY KEY (id); + + +-- +-- Name: CollectionJob CollectionJob_testPlanRunId_key; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_testPlanRunId_key" CASCADE; +ALTER TABLE ONLY public."CollectionJob" + ADD CONSTRAINT "CollectionJob_testPlanRunId_key" UNIQUE ("testPlanRunId"); + + +-- +-- Name: Role Role_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."Role" DROP CONSTRAINT IF EXISTS "Role_pkey" CASCADE; +ALTER TABLE ONLY public."Role" + ADD CONSTRAINT "Role_pkey" PRIMARY KEY (name); + + +-- +-- Name: SequelizeMeta SequelizeMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."SequelizeMeta" DROP CONSTRAINT IF EXISTS "SequelizeMeta_pkey" CASCADE; +ALTER TABLE ONLY public."SequelizeMeta" + ADD CONSTRAINT "SequelizeMeta_pkey" PRIMARY KEY (name); + + +-- +-- Name: TestPlanReport TestPlanReport_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_pkey" CASCADE; +ALTER TABLE ONLY public."TestPlanReport" + ADD CONSTRAINT "TestPlanReport_pkey" PRIMARY KEY (id); + + +-- +-- Name: TestPlanRun TestPlanRun_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_pkey" CASCADE; +ALTER TABLE ONLY public."TestPlanRun" + ADD CONSTRAINT "TestPlanRun_pkey" PRIMARY KEY (id); + + +-- +-- Name: TestPlanVersion TestPlanVersion_hashedTests_key; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlanVersion_hashedTests_key" CASCADE; +ALTER TABLE ONLY public."TestPlanVersion" + ADD CONSTRAINT "TestPlanVersion_hashedTests_key" UNIQUE ("hashedTests"); + + +-- +-- Name: TestPlanVersion TestPlan_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlan_pkey" CASCADE; +ALTER TABLE ONLY public."TestPlanVersion" + ADD CONSTRAINT "TestPlan_pkey" PRIMARY KEY (id); + + +-- +-- Name: TestPlan TestPlan_pkey1; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlan" DROP CONSTRAINT IF EXISTS "TestPlan_pkey1" CASCADE; +ALTER TABLE ONLY public."TestPlan" + ADD CONSTRAINT "TestPlan_pkey1" PRIMARY KEY (id); + + +-- +-- Name: UserRoles UserRoles_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_pkey" CASCADE; +ALTER TABLE ONLY public."UserRoles" + ADD CONSTRAINT "UserRoles_pkey" PRIMARY KEY ("userId", "roleName"); + + +-- +-- Name: User User_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."User" DROP CONSTRAINT IF EXISTS "User_pkey" CASCADE; +ALTER TABLE ONLY public."User" + ADD CONSTRAINT "User_pkey" PRIMARY KEY (id); + + +-- +-- Name: User User_username_key; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."User" DROP CONSTRAINT IF EXISTS "User_username_key" CASCADE; +ALTER TABLE ONLY public."User" + ADD CONSTRAINT "User_username_key" UNIQUE (username); + + +-- +-- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public.session DROP CONSTRAINT IF EXISTS session_pkey CASCADE; +ALTER TABLE ONLY public.session + ADD CONSTRAINT session_pkey PRIMARY KEY (sid); + + +-- +-- Name: TestPlanVersion uniqueVersionStringByDirectory; Type: CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "uniqueVersionStringByDirectory" CASCADE; +ALTER TABLE ONLY public."TestPlanVersion" + ADD CONSTRAINT "uniqueVersionStringByDirectory" UNIQUE (directory, "versionString"); + + +-- +-- Name: IDX_session_expire; Type: INDEX; Schema: public; Owner: atr +-- + +CREATE INDEX IF NOT EXISTS "IDX_session_expire" ON public.session USING btree (expire); + + +-- +-- Name: AtBrowsers AtBrowsers_atId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."AtBrowsers" DROP CONSTRAINT IF EXISTS "AtBrowsers_atId_fkey" CASCADE; +ALTER TABLE ONLY public."AtBrowsers" + ADD CONSTRAINT "AtBrowsers_atId_fkey" FOREIGN KEY ("atId") REFERENCES public."At"(id); + + +-- +-- Name: AtBrowsers AtBrowsers_browserId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."AtBrowsers" DROP CONSTRAINT IF EXISTS "AtBrowsers_browserId_fkey" CASCADE; +ALTER TABLE ONLY public."AtBrowsers" + ADD CONSTRAINT "AtBrowsers_browserId_fkey" FOREIGN KEY ("browserId") REFERENCES public."Browser"(id); + + +-- +-- Name: AtVersion AtVersion_at_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_at_fkey" CASCADE; +ALTER TABLE ONLY public."AtVersion" + ADD CONSTRAINT "AtVersion_at_fkey" FOREIGN KEY ("atId") REFERENCES public."At"(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: BrowserVersion BrowserVersion_browser_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_browser_fkey" CASCADE; +ALTER TABLE ONLY public."BrowserVersion" + ADD CONSTRAINT "BrowserVersion_browser_fkey" FOREIGN KEY ("browserId") REFERENCES public."Browser"(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: CollectionJobTestStatus CollectionJobTestStatus_collectionJobId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJobTestStatus_collectionJobId_fkey" CASCADE; +ALTER TABLE ONLY public."CollectionJobTestStatus" + ADD CONSTRAINT "CollectionJobTestStatus_collectionJobId_fkey" FOREIGN KEY ("collectionJobId") REFERENCES public."CollectionJob"(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: CollectionJob CollectionJob_testPlanRunId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_testPlanRunId_fkey" CASCADE; +ALTER TABLE ONLY public."CollectionJob" + ADD CONSTRAINT "CollectionJob_testPlanRunId_fkey" FOREIGN KEY ("testPlanRunId") REFERENCES public."TestPlanRun"(id) ON DELETE SET NULL; + + +-- +-- Name: TestPlanReport TestPlanReport_testPlanId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlanId_fkey" CASCADE; +ALTER TABLE ONLY public."TestPlanReport" + ADD CONSTRAINT "TestPlanReport_testPlanId_fkey" FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id); + + +-- +-- Name: TestPlanReport TestPlanReport_testPlan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlan_fkey" CASCADE; +ALTER TABLE ONLY public."TestPlanReport" + ADD CONSTRAINT "TestPlanReport_testPlan_fkey" FOREIGN KEY ("testPlanVersionId") REFERENCES public."TestPlanVersion"(id) ON UPDATE CASCADE; + + +-- +-- Name: TestPlanRun TestPlanRun_testPlanReport_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_testPlanReport_fkey" CASCADE; +ALTER TABLE ONLY public."TestPlanRun" + ADD CONSTRAINT "TestPlanRun_testPlanReport_fkey" FOREIGN KEY ("testPlanReportId") REFERENCES public."TestPlanReport"(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: TestPlanRun TestPlanRun_tester_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_tester_fkey" CASCADE; +ALTER TABLE ONLY public."TestPlanRun" + ADD CONSTRAINT "TestPlanRun_tester_fkey" FOREIGN KEY ("testerUserId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE SET NULL; + + +-- +-- Name: TestPlanVersion TestPlanVersion_testPlanId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlanVersion_testPlanId_fkey" CASCADE; +ALTER TABLE ONLY public."TestPlanVersion" + ADD CONSTRAINT "TestPlanVersion_testPlanId_fkey" FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id); + + +-- +-- Name: UserRoles UserRoles_roleName_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_roleName_fkey" CASCADE; +ALTER TABLE ONLY public."UserRoles" + ADD CONSTRAINT "UserRoles_roleName_fkey" FOREIGN KEY ("roleName") REFERENCES public."Role"(name) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: UserRoles UserRoles_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr +-- + +ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_userId_fkey" CASCADE; +ALTER TABLE ONLY public."UserRoles" + ADD CONSTRAINT "UserRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- + From 65469c1afb18bd31b1a79ef83b55d8add5872072 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 09:47:34 -0400 Subject: [PATCH 04/10] Remove unnecessary older dumps --- .../migrations/pg_dump_2021_05_new_schema.sql | 819 ----------- .../pg_dump_from_flyway_migrations.dump | 1272 ----------------- 2 files changed, 2091 deletions(-) delete mode 100644 server/migrations/pg_dump_2021_05_new_schema.sql delete mode 100644 server/migrations/pg_dump_from_flyway_migrations.dump diff --git a/server/migrations/pg_dump_2021_05_new_schema.sql b/server/migrations/pg_dump_2021_05_new_schema.sql deleted file mode 100644 index 7314114c5..000000000 --- a/server/migrations/pg_dump_2021_05_new_schema.sql +++ /dev/null @@ -1,819 +0,0 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 13.2 but modified manually to support Postgres 11 - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - -ALTER TABLE IF EXISTS ONLY public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_userId_fkey"; -ALTER TABLE IF EXISTS ONLY public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_roleName_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestResult" DROP CONSTRAINT IF EXISTS "TestResult_testPlanRun_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanTarget" DROP CONSTRAINT IF EXISTS "TestPlanTarget_browser_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanTarget" DROP CONSTRAINT IF EXISTS "TestPlanTarget_browserVersion_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanTarget" DROP CONSTRAINT IF EXISTS "TestPlanTarget_at_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanTarget" DROP CONSTRAINT IF EXISTS "TestPlanTarget_atVersion_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_tester_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_testPlanReport_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlan_fkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlanTarget_fkey"; -ALTER TABLE IF EXISTS ONLY public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_browser_fkey"; -ALTER TABLE IF EXISTS ONLY public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_at_fkey"; -ALTER TABLE IF EXISTS ONLY public."AtMode" DROP CONSTRAINT IF EXISTS "AtMode_at_fkey"; -ALTER TABLE IF EXISTS ONLY public."User" DROP CONSTRAINT IF EXISTS "User_username_key"; -ALTER TABLE IF EXISTS ONLY public."User" DROP CONSTRAINT IF EXISTS "User_pkey"; -ALTER TABLE IF EXISTS ONLY public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_pkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlan" DROP CONSTRAINT IF EXISTS "TestPlan_pkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanTarget" DROP CONSTRAINT IF EXISTS "TestPlanTarget_pkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_pkey"; -ALTER TABLE IF EXISTS ONLY public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_pkey"; -ALTER TABLE IF EXISTS ONLY public."Role" DROP CONSTRAINT IF EXISTS "Role_pkey"; -ALTER TABLE IF EXISTS ONLY public."Browser" DROP CONSTRAINT IF EXISTS "Browser_pkey"; -ALTER TABLE IF EXISTS ONLY public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_version_key"; -ALTER TABLE IF EXISTS ONLY public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_pkey"; -ALTER TABLE IF EXISTS ONLY public."At" DROP CONSTRAINT IF EXISTS "At_pkey"; -ALTER TABLE IF EXISTS ONLY public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_version_key"; -ALTER TABLE IF EXISTS ONLY public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_pkey"; -ALTER TABLE IF EXISTS ONLY public."AtMode" DROP CONSTRAINT IF EXISTS "AtMode_pkey"; -ALTER TABLE IF EXISTS public."User" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."TestPlanTarget" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."TestPlanRun" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."TestPlanReport" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."TestPlan" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."Browser" ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public."At" ALTER COLUMN id DROP DEFAULT; -DROP SEQUENCE IF EXISTS public."User_id_seq"; -DROP TABLE IF EXISTS public."UserRoles"; -DROP TABLE IF EXISTS public."User"; -DROP TABLE IF EXISTS public."TestResult"; -DROP SEQUENCE IF EXISTS public."TestPlan_id_seq"; -DROP SEQUENCE IF EXISTS public."TestPlanTarget_id_seq"; -DROP TABLE IF EXISTS public."TestPlanTarget"; -DROP SEQUENCE IF EXISTS public."TestPlanRun_id_seq"; -DROP TABLE IF EXISTS public."TestPlanRun"; -DROP SEQUENCE IF EXISTS public."TestPlanReport_id_seq"; -DROP TABLE IF EXISTS public."TestPlanReport"; -DROP TABLE IF EXISTS public."TestPlan"; -DROP TABLE IF EXISTS public."Role"; -DROP SEQUENCE IF EXISTS public."Browser_id_seq"; -DROP TABLE IF EXISTS public."BrowserVersion"; -DROP TABLE IF EXISTS public."Browser"; -DROP SEQUENCE IF EXISTS public."At_id_seq"; -DROP TABLE IF EXISTS public."AtVersion"; -DROP TABLE IF EXISTS public."AtMode"; -DROP TABLE IF EXISTS public."At"; -SET default_tablespace = ''; - --- Prevents import into Postgres 11 database --- SET default_table_access_method = heap; - --- --- Name: At; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."At" ( - id integer NOT NULL, - name text NOT NULL -); - - -ALTER TABLE public."At" OWNER TO atr; - --- --- Name: AtMode; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."AtMode" ( - at integer NOT NULL, - name text NOT NULL -); - - -ALTER TABLE public."AtMode" OWNER TO atr; - --- --- Name: AtVersion; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."AtVersion" ( - at integer NOT NULL, - version text NOT NULL -); - - -ALTER TABLE public."AtVersion" OWNER TO atr; - --- --- Name: At_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."At_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."At_id_seq" OWNER TO atr; - --- --- Name: At_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."At_id_seq" OWNED BY public."At".id; - - --- --- Name: Browser; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."Browser" ( - id integer NOT NULL, - name text NOT NULL -); - - -ALTER TABLE public."Browser" OWNER TO atr; - --- --- Name: BrowserVersion; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."BrowserVersion" ( - browser integer NOT NULL, - version text NOT NULL -); - - -ALTER TABLE public."BrowserVersion" OWNER TO atr; - --- --- Name: Browser_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."Browser_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."Browser_id_seq" OWNER TO atr; - --- --- Name: Browser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."Browser_id_seq" OWNED BY public."Browser".id; - - --- --- Name: Role; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."Role" ( - name text NOT NULL -); - - -ALTER TABLE public."Role" OWNER TO atr; - --- --- Name: TestPlan; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."TestPlan" ( - id integer NOT NULL, - title text, - "publishStatus" text, - "sourceGitCommitHash" text, - "sourceGitCommitMessage" text, - "exampleUrl" text, - "createdAt" timestamp with time zone, - parsed jsonb -); - - -ALTER TABLE public."TestPlan" OWNER TO atr; - --- --- Name: TestPlanReport; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."TestPlanReport" ( - id integer NOT NULL, - "publishStatus" text, - "testPlanTarget" integer, - "testPlan" integer, - "coveragePercent" numeric, - "createdAt" timestamp with time zone -); - - -ALTER TABLE public."TestPlanReport" OWNER TO atr; - --- --- Name: TestPlanReport_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."TestPlanReport_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."TestPlanReport_id_seq" OWNER TO atr; - --- --- Name: TestPlanReport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."TestPlanReport_id_seq" OWNED BY public."TestPlanReport".id; - - --- --- Name: TestPlanRun; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."TestPlanRun" ( - id integer NOT NULL, - "isManuallyTested" boolean, - tester integer, - "testPlanReport" integer -); - - -ALTER TABLE public."TestPlanRun" OWNER TO atr; - --- --- Name: TestPlanRun_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."TestPlanRun_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."TestPlanRun_id_seq" OWNER TO atr; - --- --- Name: TestPlanRun_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."TestPlanRun_id_seq" OWNED BY public."TestPlanRun".id; - - --- --- Name: TestPlanTarget; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."TestPlanTarget" ( - id integer NOT NULL, - title text, - at integer, - browser integer, - "atVersion" text, - "browserVersion" text -); - - -ALTER TABLE public."TestPlanTarget" OWNER TO atr; - --- --- Name: TestPlanTarget_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."TestPlanTarget_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."TestPlanTarget_id_seq" OWNER TO atr; - --- --- Name: TestPlanTarget_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."TestPlanTarget_id_seq" OWNED BY public."TestPlanTarget".id; - - --- --- Name: TestPlan_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."TestPlan_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."TestPlan_id_seq" OWNER TO atr; - --- --- Name: TestPlan_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."TestPlan_id_seq" OWNED BY public."TestPlan".id; - - --- --- Name: TestResult; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."TestResult" ( - "startedAt" timestamp with time zone, - "completedAt" timestamp with time zone, - "testPlanRun" integer, - data jsonb -); - - -ALTER TABLE public."TestResult" OWNER TO atr; - --- --- Name: User; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."User" ( - id integer NOT NULL, - username text NOT NULL, - "createdAt" timestamp with time zone, - "updatedAt" timestamp with time zone -); - - -ALTER TABLE public."User" OWNER TO atr; - --- --- Name: UserRoles; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public."UserRoles" ( - "userId" integer NOT NULL, - "roleName" text NOT NULL -); - - -ALTER TABLE public."UserRoles" OWNER TO atr; - --- --- Name: User_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public."User_id_seq" - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public."User_id_seq" OWNER TO atr; - --- --- Name: User_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public."User_id_seq" OWNED BY public."User".id; - - --- --- Name: At id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."At" ALTER COLUMN id SET DEFAULT nextval('public."At_id_seq"'::regclass); - - --- --- Name: Browser id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."Browser" ALTER COLUMN id SET DEFAULT nextval('public."Browser_id_seq"'::regclass); - - --- --- Name: TestPlan id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlan" ALTER COLUMN id SET DEFAULT nextval('public."TestPlan_id_seq"'::regclass); - - --- --- Name: TestPlanReport id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanReport" ALTER COLUMN id SET DEFAULT nextval('public."TestPlanReport_id_seq"'::regclass); - - --- --- Name: TestPlanRun id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanRun" ALTER COLUMN id SET DEFAULT nextval('public."TestPlanRun_id_seq"'::regclass); - - --- --- Name: TestPlanTarget id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" ALTER COLUMN id SET DEFAULT nextval('public."TestPlanTarget_id_seq"'::regclass); - - --- --- Name: User id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."User" ALTER COLUMN id SET DEFAULT nextval('public."User_id_seq"'::regclass); - - --- --- Data for Name: At; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: AtMode; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: AtVersion; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: Browser; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: BrowserVersion; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: Role; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlan; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanReport; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanRun; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanTarget; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestResult; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: User; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: UserRoles; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Name: At_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."At_id_seq"', 1, false); - - --- --- Name: Browser_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."Browser_id_seq"', 1, false); - - --- --- Name: TestPlanReport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlanReport_id_seq"', 1, false); - - --- --- Name: TestPlanRun_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlanRun_id_seq"', 1, false); - - --- --- Name: TestPlanTarget_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlanTarget_id_seq"', 1, false); - - --- --- Name: TestPlan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlan_id_seq"', 1, false); - - --- --- Name: User_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."User_id_seq"', 1, false); - - --- --- Name: AtMode AtMode_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."AtMode" - ADD CONSTRAINT "AtMode_pkey" PRIMARY KEY (at, name); - - --- --- Name: AtVersion AtVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."AtVersion" - ADD CONSTRAINT "AtVersion_pkey" PRIMARY KEY (at, version); - - --- --- Name: AtVersion AtVersion_version_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."AtVersion" - ADD CONSTRAINT "AtVersion_version_key" UNIQUE (version); - - --- --- Name: At At_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."At" - ADD CONSTRAINT "At_pkey" PRIMARY KEY (id); - - --- --- Name: BrowserVersion BrowserVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."BrowserVersion" - ADD CONSTRAINT "BrowserVersion_pkey" PRIMARY KEY (browser, version); - - --- --- Name: BrowserVersion BrowserVersion_version_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."BrowserVersion" - ADD CONSTRAINT "BrowserVersion_version_key" UNIQUE (version); - - --- --- Name: Browser Browser_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."Browser" - ADD CONSTRAINT "Browser_pkey" PRIMARY KEY (id); - - --- --- Name: Role Role_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."Role" - ADD CONSTRAINT "Role_pkey" PRIMARY KEY (name); - - --- --- Name: TestPlanReport TestPlanReport_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_pkey" PRIMARY KEY (id); - - --- --- Name: TestPlanRun TestPlanRun_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_pkey" PRIMARY KEY (id); - - --- --- Name: TestPlanTarget TestPlanTarget_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" - ADD CONSTRAINT "TestPlanTarget_pkey" PRIMARY KEY (id); - - --- --- Name: TestPlan TestPlan_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlan" - ADD CONSTRAINT "TestPlan_pkey" PRIMARY KEY (id); - - --- --- Name: UserRoles UserRoles_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_pkey" PRIMARY KEY ("userId", "roleName"); - - --- --- Name: User User_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."User" - ADD CONSTRAINT "User_pkey" PRIMARY KEY (id); - - --- --- Name: User User_username_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."User" - ADD CONSTRAINT "User_username_key" UNIQUE (username); - - --- --- Name: AtMode AtMode_at_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."AtMode" - ADD CONSTRAINT "AtMode_at_fkey" FOREIGN KEY (at) REFERENCES public."At"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: AtVersion AtVersion_at_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."AtVersion" - ADD CONSTRAINT "AtVersion_at_fkey" FOREIGN KEY (at) REFERENCES public."At"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: BrowserVersion BrowserVersion_browser_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."BrowserVersion" - ADD CONSTRAINT "BrowserVersion_browser_fkey" FOREIGN KEY (browser) REFERENCES public."Browser"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: TestPlanReport TestPlanReport_testPlanTarget_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_testPlanTarget_fkey" FOREIGN KEY ("testPlanTarget") REFERENCES public."TestPlanTarget"(id) ON UPDATE CASCADE; - - --- --- Name: TestPlanReport TestPlanReport_testPlan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_testPlan_fkey" FOREIGN KEY ("testPlan") REFERENCES public."TestPlan"(id) ON UPDATE CASCADE; - - --- --- Name: TestPlanRun TestPlanRun_testPlanReport_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_testPlanReport_fkey" FOREIGN KEY ("testPlanReport") REFERENCES public."TestPlanReport"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: TestPlanRun TestPlanRun_tester_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_tester_fkey" FOREIGN KEY (tester) REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE SET NULL; - - --- --- Name: TestPlanTarget TestPlanTarget_atVersion_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" - ADD CONSTRAINT "TestPlanTarget_atVersion_fkey" FOREIGN KEY ("atVersion") REFERENCES public."AtVersion"(version); - - --- --- Name: TestPlanTarget TestPlanTarget_at_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" - ADD CONSTRAINT "TestPlanTarget_at_fkey" FOREIGN KEY (at) REFERENCES public."At"(id) ON UPDATE CASCADE; - - --- --- Name: TestPlanTarget TestPlanTarget_browserVersion_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" - ADD CONSTRAINT "TestPlanTarget_browserVersion_fkey" FOREIGN KEY ("browserVersion") REFERENCES public."BrowserVersion"(version); - - --- --- Name: TestPlanTarget TestPlanTarget_browser_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestPlanTarget" - ADD CONSTRAINT "TestPlanTarget_browser_fkey" FOREIGN KEY (browser) REFERENCES public."Browser"(id) ON UPDATE CASCADE; - - --- --- Name: TestResult TestResult_testPlanRun_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."TestResult" - ADD CONSTRAINT "TestResult_testPlanRun_fkey" FOREIGN KEY ("testPlanRun") REFERENCES public."TestPlanRun"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: UserRoles UserRoles_roleName_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_roleName_fkey" FOREIGN KEY ("roleName") REFERENCES public."Role"(name) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- Name: UserRoles UserRoles_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE CASCADE; - - --- --- PostgreSQL database dump complete --- - diff --git a/server/migrations/pg_dump_from_flyway_migrations.dump b/server/migrations/pg_dump_from_flyway_migrations.dump deleted file mode 100644 index b49cb4123..000000000 --- a/server/migrations/pg_dump_from_flyway_migrations.dump +++ /dev/null @@ -1,1272 +0,0 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 11.7 (Debian 11.7-0+deb10u1) --- Dumped by pg_dump version 11.7 (Debian 11.7-0+deb10u1) - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - -SET default_tablespace = ''; - -SET default_with_oids = false; - --- --- Name: apg_example; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.apg_example ( - id integer NOT NULL, - directory text, - name text, - test_version_id integer NOT NULL -); - - -ALTER TABLE public.apg_example OWNER TO atr; - --- --- Name: apg_example_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.apg_example_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.apg_example_id_seq OWNER TO atr; - --- --- Name: apg_example_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.apg_example_id_seq OWNED BY public.apg_example.id; - - --- --- Name: at; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.at ( - id integer NOT NULL, - key text, - at_name_id integer NOT NULL, - test_version_id integer NOT NULL -); - - -ALTER TABLE public.at OWNER TO atr; - --- --- Name: at_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.at_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.at_id_seq OWNER TO atr; - --- --- Name: at_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.at_id_seq OWNED BY public.at.id; - - --- --- Name: at_name; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.at_name ( - id integer NOT NULL, - name text -); - - -ALTER TABLE public.at_name OWNER TO atr; - --- --- Name: at_name_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.at_name_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.at_name_id_seq OWNER TO atr; - --- --- Name: at_name_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.at_name_id_seq OWNED BY public.at_name.id; - - --- --- Name: at_version; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.at_version ( - id integer NOT NULL, - at_name_id integer NOT NULL, - version character varying(256), - release_order integer -); - - -ALTER TABLE public.at_version OWNER TO atr; - --- --- Name: at_version_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.at_version_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.at_version_id_seq OWNER TO atr; - --- --- Name: at_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.at_version_id_seq OWNED BY public.at_version.id; - - --- --- Name: browser; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.browser ( - id integer NOT NULL, - name text -); - - -ALTER TABLE public.browser OWNER TO atr; - --- --- Name: browser_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.browser_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.browser_id_seq OWNER TO atr; - --- --- Name: browser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.browser_id_seq OWNED BY public.browser.id; - - --- --- Name: browser_version; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.browser_version ( - id integer NOT NULL, - browser_id integer NOT NULL, - version character varying(256), - release_order integer -); - - -ALTER TABLE public.browser_version OWNER TO atr; - --- --- Name: browser_version_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.browser_version_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.browser_version_id_seq OWNER TO atr; - --- --- Name: browser_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.browser_version_id_seq OWNED BY public.browser_version.id; - - --- --- Name: role; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.role ( - id integer NOT NULL, - name text -); - - -ALTER TABLE public.role OWNER TO atr; - --- --- Name: role_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.role_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.role_id_seq OWNER TO atr; - --- --- Name: role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.role_id_seq OWNED BY public.role.id; - - --- --- Name: run; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.run ( - id integer NOT NULL, - test_cycle_id integer NOT NULL, - at_version_id integer NOT NULL, - at_id integer NOT NULL, - browser_version_id integer NOT NULL, - apg_example_id integer NOT NULL -); - - -ALTER TABLE public.run OWNER TO atr; - --- --- Name: run_data; Type: VIEW; Schema: public; Owner: atr --- - -CREATE VIEW public.run_data AS - SELECT run.id, - run.test_cycle_id, - browser_version.version AS browser_version, - browser.name AS browser_name, - browser.id AS browser_id, - at.key AS at_key, - at.id AS at_id, - at_name.name AS at_name, - at_name.id AS at_name_id, - at_version.version AS at_version, - apg_example.directory AS apg_example_directory, - apg_example.name AS apg_example_name, - apg_example.id AS apg_example_id - FROM public.run, - public.browser_version, - public.browser, - public.at, - public.at_name, - public.at_version, - public.apg_example - WHERE ((run.browser_version_id = browser_version.id) AND (browser_version.browser_id = browser.id) AND (run.at_id = at.id) AND (at.at_name_id = at_name.id) AND (run.at_version_id = at_version.id) AND (run.apg_example_id = apg_example.id)); - - -ALTER TABLE public.run_data OWNER TO atr; - --- --- Name: run_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.run_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.run_id_seq OWNER TO atr; - --- --- Name: run_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.run_id_seq OWNED BY public.run.id; - - --- --- Name: session; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.session ( - sid character varying NOT NULL, - sess jsonb NOT NULL, - expire timestamp(6) without time zone NOT NULL -); - - -ALTER TABLE public.session OWNER TO atr; - --- --- Name: test; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test ( - id integer NOT NULL, - name text, - file text, - execution_order integer, - apg_example_id integer NOT NULL, - test_version_id integer NOT NULL -); - - -ALTER TABLE public.test OWNER TO atr; - --- --- Name: test_cycle; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test_cycle ( - id integer NOT NULL, - name text, - test_version_id integer NOT NULL, - created_user_id integer NOT NULL, - date date -); - - -ALTER TABLE public.test_cycle OWNER TO atr; - --- --- Name: test_cycle_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_cycle_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_cycle_id_seq OWNER TO atr; - --- --- Name: test_cycle_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_cycle_id_seq OWNED BY public.test_cycle.id; - - --- --- Name: test_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_id_seq OWNER TO atr; - --- --- Name: test_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_id_seq OWNED BY public.test.id; - - --- --- Name: test_result; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test_result ( - id integer NOT NULL, - test_id integer NOT NULL, - run_id integer NOT NULL, - user_id integer NOT NULL, - status_id integer, - result jsonb -); - - -ALTER TABLE public.test_result OWNER TO atr; - --- --- Name: test_result_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_result_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_result_id_seq OWNER TO atr; - --- --- Name: test_result_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_result_id_seq OWNED BY public.test_result.id; - - --- --- Name: test_status; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test_status ( - id integer NOT NULL, - name text -); - - -ALTER TABLE public.test_status OWNER TO atr; - --- --- Name: test_status_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_status_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_status_id_seq OWNER TO atr; - --- --- Name: test_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_status_id_seq OWNED BY public.test_status.id; - - --- --- Name: test_to_at; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test_to_at ( - id integer NOT NULL, - test_id integer NOT NULL, - at_id integer NOT NULL -); - - -ALTER TABLE public.test_to_at OWNER TO atr; - --- --- Name: test_to_at_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_to_at_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_to_at_id_seq OWNER TO atr; - --- --- Name: test_to_at_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_to_at_id_seq OWNED BY public.test_to_at.id; - - --- --- Name: test_version; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.test_version ( - id integer NOT NULL, - git_repo text, - git_tag text, - git_hash text, - git_commit_msg text, - datetime timestamp with time zone -); - - -ALTER TABLE public.test_version OWNER TO atr; - --- --- Name: test_version_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.test_version_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.test_version_id_seq OWNER TO atr; - --- --- Name: test_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.test_version_id_seq OWNED BY public.test_version.id; - - --- --- Name: tester_to_run; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.tester_to_run ( - id integer NOT NULL, - run_id integer NOT NULL, - user_id integer NOT NULL -); - - -ALTER TABLE public.tester_to_run OWNER TO atr; - --- --- Name: tester_to_run_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.tester_to_run_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.tester_to_run_id_seq OWNER TO atr; - --- --- Name: tester_to_run_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.tester_to_run_id_seq OWNED BY public.tester_to_run.id; - - --- --- Name: user_to_at; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.user_to_at ( - id integer NOT NULL, - at_name_id integer NOT NULL, - user_id integer NOT NULL, - active boolean -); - - -ALTER TABLE public.user_to_at OWNER TO atr; - --- --- Name: user_to_at_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.user_to_at_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.user_to_at_id_seq OWNER TO atr; - --- --- Name: user_to_at_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.user_to_at_id_seq OWNED BY public.user_to_at.id; - - --- --- Name: user_to_role; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.user_to_role ( - id integer NOT NULL, - user_id integer NOT NULL, - role_id integer NOT NULL -); - - -ALTER TABLE public.user_to_role OWNER TO atr; - --- --- Name: user_to_role_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.user_to_role_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.user_to_role_id_seq OWNER TO atr; - --- --- Name: user_to_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.user_to_role_id_seq OWNED BY public.user_to_role.id; - - --- --- Name: users; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE public.users ( - id integer NOT NULL, - fullname text, - username text, - email text -); - - -ALTER TABLE public.users OWNER TO atr; - --- --- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: atr --- - -CREATE SEQUENCE public.users_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.users_id_seq OWNER TO atr; - --- --- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atr --- - -ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; - - --- --- Name: apg_example id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.apg_example ALTER COLUMN id SET DEFAULT nextval('public.apg_example_id_seq'::regclass); - - --- --- Name: at id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at ALTER COLUMN id SET DEFAULT nextval('public.at_id_seq'::regclass); - - --- --- Name: at_name id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_name ALTER COLUMN id SET DEFAULT nextval('public.at_name_id_seq'::regclass); - - --- --- Name: at_version id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_version ALTER COLUMN id SET DEFAULT nextval('public.at_version_id_seq'::regclass); - - --- --- Name: browser id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser ALTER COLUMN id SET DEFAULT nextval('public.browser_id_seq'::regclass); - - --- --- Name: browser_version id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser_version ALTER COLUMN id SET DEFAULT nextval('public.browser_version_id_seq'::regclass); - - --- --- Name: role id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.role ALTER COLUMN id SET DEFAULT nextval('public.role_id_seq'::regclass); - - --- --- Name: run id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run ALTER COLUMN id SET DEFAULT nextval('public.run_id_seq'::regclass); - - --- --- Name: test id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test ALTER COLUMN id SET DEFAULT nextval('public.test_id_seq'::regclass); - - --- --- Name: test_cycle id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_cycle ALTER COLUMN id SET DEFAULT nextval('public.test_cycle_id_seq'::regclass); - - --- --- Name: test_result id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result ALTER COLUMN id SET DEFAULT nextval('public.test_result_id_seq'::regclass); - - --- --- Name: test_status id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_status ALTER COLUMN id SET DEFAULT nextval('public.test_status_id_seq'::regclass); - - --- --- Name: test_to_at id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_to_at ALTER COLUMN id SET DEFAULT nextval('public.test_to_at_id_seq'::regclass); - - --- --- Name: test_version id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_version ALTER COLUMN id SET DEFAULT nextval('public.test_version_id_seq'::regclass); - - --- --- Name: tester_to_run id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.tester_to_run ALTER COLUMN id SET DEFAULT nextval('public.tester_to_run_id_seq'::regclass); - - --- --- Name: user_to_at id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_at ALTER COLUMN id SET DEFAULT nextval('public.user_to_at_id_seq'::regclass); - - --- --- Name: user_to_role id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_role ALTER COLUMN id SET DEFAULT nextval('public.user_to_role_id_seq'::regclass); - - --- --- Name: users id; Type: DEFAULT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); - - --- --- Name: apg_example apg_example_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.apg_example - ADD CONSTRAINT apg_example_pkey PRIMARY KEY (id); - - --- --- Name: at_name at_name_name_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_name - ADD CONSTRAINT at_name_name_key UNIQUE (name); - - --- --- Name: at_name at_name_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_name - ADD CONSTRAINT at_name_pkey PRIMARY KEY (id); - - --- --- Name: at at_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at - ADD CONSTRAINT at_pkey PRIMARY KEY (id); - - --- --- Name: at_version at_version_at_name_id_version_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_version - ADD CONSTRAINT at_version_at_name_id_version_key UNIQUE (at_name_id, version); - - --- --- Name: at_version at_version_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_version - ADD CONSTRAINT at_version_pkey PRIMARY KEY (id); - - --- --- Name: browser browser_name_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser - ADD CONSTRAINT browser_name_key UNIQUE (name); - - --- --- Name: browser browser_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser - ADD CONSTRAINT browser_pkey PRIMARY KEY (id); - - --- --- Name: browser_version browser_version_browser_id_version_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser_version - ADD CONSTRAINT browser_version_browser_id_version_key UNIQUE (browser_id, version); - - --- --- Name: browser_version browser_version_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser_version - ADD CONSTRAINT browser_version_pkey PRIMARY KEY (id); - - --- --- Name: role role_name_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.role - ADD CONSTRAINT role_name_key UNIQUE (name); - - --- --- Name: role role_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.role - ADD CONSTRAINT role_pkey PRIMARY KEY (id); - - --- --- Name: run run_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_pkey PRIMARY KEY (id); - - --- --- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.session - ADD CONSTRAINT session_pkey PRIMARY KEY (sid); - - --- --- Name: test_cycle test_cycle_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_cycle - ADD CONSTRAINT test_cycle_pkey PRIMARY KEY (id); - - --- --- Name: test test_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test - ADD CONSTRAINT test_pkey PRIMARY KEY (id); - - --- --- Name: test_result test_result_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result - ADD CONSTRAINT test_result_pkey PRIMARY KEY (id); - - --- --- Name: test_status test_status_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_status - ADD CONSTRAINT test_status_pkey PRIMARY KEY (id); - - --- --- Name: test_to_at test_to_at_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_to_at - ADD CONSTRAINT test_to_at_pkey PRIMARY KEY (id); - - --- --- Name: test_version test_version_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_version - ADD CONSTRAINT test_version_pkey PRIMARY KEY (id); - - --- --- Name: tester_to_run tester_to_run_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.tester_to_run - ADD CONSTRAINT tester_to_run_pkey PRIMARY KEY (id); - - --- --- Name: user_to_at user_to_at_at_name_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_at - ADD CONSTRAINT user_to_at_at_name_id_user_id_key UNIQUE (at_name_id, user_id); - - --- --- Name: user_to_at user_to_at_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_at - ADD CONSTRAINT user_to_at_pkey PRIMARY KEY (id); - - --- --- Name: user_to_role user_to_role_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_role - ADD CONSTRAINT user_to_role_pkey PRIMARY KEY (id); - - --- --- Name: user_to_role user_to_role_user_id_role_id_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_role - ADD CONSTRAINT user_to_role_user_id_role_id_key UNIQUE (user_id, role_id); - - --- --- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_pkey PRIMARY KEY (id); - - --- --- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_username_key UNIQUE (username); - - --- --- Name: IDX_session_expire; Type: INDEX; Schema: public; Owner: atr --- - -CREATE INDEX "IDX_session_expire" ON public.session USING btree (expire); - - - --- --- Name: apg_example apg_example_test_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.apg_example - ADD CONSTRAINT apg_example_test_version_id_fkey FOREIGN KEY (test_version_id) REFERENCES public.test_version(id); - - --- --- Name: at at_at_name_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at - ADD CONSTRAINT at_at_name_id_fkey FOREIGN KEY (at_name_id) REFERENCES public.at_name(id); - - --- --- Name: at at_test_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at - ADD CONSTRAINT at_test_version_id_fkey FOREIGN KEY (test_version_id) REFERENCES public.test_version(id); - - --- --- Name: at_version at_version_at_name_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.at_version - ADD CONSTRAINT at_version_at_name_id_fkey FOREIGN KEY (at_name_id) REFERENCES public.at_name(id); - - --- --- Name: browser_version browser_version_browser_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.browser_version - ADD CONSTRAINT browser_version_browser_id_fkey FOREIGN KEY (browser_id) REFERENCES public.browser(id); - - --- --- Name: run run_apg_example_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_apg_example_id_fkey FOREIGN KEY (apg_example_id) REFERENCES public.apg_example(id); - - --- --- Name: run run_at_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_at_id_fkey FOREIGN KEY (at_id) REFERENCES public.at(id); - - --- --- Name: run run_at_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_at_version_id_fkey FOREIGN KEY (at_version_id) REFERENCES public.at_version(id); - - --- --- Name: run run_browser_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_browser_version_id_fkey FOREIGN KEY (browser_version_id) REFERENCES public.browser_version(id); - - --- --- Name: run run_test_cycle_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.run - ADD CONSTRAINT run_test_cycle_id_fkey FOREIGN KEY (test_cycle_id) REFERENCES public.test_cycle(id); - - --- --- Name: test test_apg_example_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test - ADD CONSTRAINT test_apg_example_id_fkey FOREIGN KEY (apg_example_id) REFERENCES public.apg_example(id); - - --- --- Name: test_cycle test_cycle_created_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_cycle - ADD CONSTRAINT test_cycle_created_user_id_fkey FOREIGN KEY (created_user_id) REFERENCES public.users(id); - - --- --- Name: test_cycle test_cycle_test_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_cycle - ADD CONSTRAINT test_cycle_test_version_id_fkey FOREIGN KEY (test_version_id) REFERENCES public.test_version(id); - - --- --- Name: test_result test_result_run_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result - ADD CONSTRAINT test_result_run_id_fkey FOREIGN KEY (run_id) REFERENCES public.run(id); - - --- --- Name: test_result test_result_status_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result - ADD CONSTRAINT test_result_status_id_fkey FOREIGN KEY (status_id) REFERENCES public.test_status(id); - - --- --- Name: test_result test_result_test_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result - ADD CONSTRAINT test_result_test_id_fkey FOREIGN KEY (test_id) REFERENCES public.test(id); - - --- --- Name: test_result test_result_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_result - ADD CONSTRAINT test_result_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: test test_test_version_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test - ADD CONSTRAINT test_test_version_id_fkey FOREIGN KEY (test_version_id) REFERENCES public.test_version(id); - - --- --- Name: test_to_at test_to_at_at_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_to_at - ADD CONSTRAINT test_to_at_at_id_fkey FOREIGN KEY (at_id) REFERENCES public.at(id); - - --- --- Name: test_to_at test_to_at_test_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.test_to_at - ADD CONSTRAINT test_to_at_test_id_fkey FOREIGN KEY (test_id) REFERENCES public.test(id); - - --- --- Name: tester_to_run tester_to_run_run_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.tester_to_run - ADD CONSTRAINT tester_to_run_run_id_fkey FOREIGN KEY (run_id) REFERENCES public.run(id); - - --- --- Name: tester_to_run tester_to_run_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.tester_to_run - ADD CONSTRAINT tester_to_run_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: user_to_at user_to_at_at_name_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_at - ADD CONSTRAINT user_to_at_at_name_id_fkey FOREIGN KEY (at_name_id) REFERENCES public.at_name(id); - - --- --- Name: user_to_at user_to_at_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_at - ADD CONSTRAINT user_to_at_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- Name: user_to_role user_to_role_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_role - ADD CONSTRAINT user_to_role_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.role(id); - - --- --- Name: user_to_role user_to_role_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE ONLY public.user_to_role - ADD CONSTRAINT user_to_role_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id); - - --- --- PostgreSQL database dump complete --- - From fc37bf4ab30128199add2dacf82142855098d8b5 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 10:34:15 -0400 Subject: [PATCH 05/10] Update migration utils --- server/migrations/utils/dumpTable.js | 23 +++++++++++++++++++ server/migrations/utils/index.js | 2 ++ server/migrations/utils/recalculateMetrics.js | 5 +++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 server/migrations/utils/dumpTable.js diff --git a/server/migrations/utils/dumpTable.js b/server/migrations/utils/dumpTable.js new file mode 100644 index 000000000..c4c597f4f --- /dev/null +++ b/server/migrations/utils/dumpTable.js @@ -0,0 +1,23 @@ +const { exec } = require('child_process'); + +/** + * Used to dump a table in case a significantly destructive behavior is to be + * done. This should make running a down migration possible if required. + * + * Ideally, also add "server/migrations/dumps/" to /.gitignore + * @param tableName + * @returns {Promise} + */ +const dumpTable = async tableName => { + try { + await exec( + `pg_dump -t '"${tableName}"' ${ + process.env.PGDATABASE + } > ${__dirname}/dumps/pg_dump_${tableName}_${new Date().getTime()}.sql` + ); + } catch (err) { + console.error(`Error dumping ${tableName}:${err}`); + } +}; + +module.exports = dumpTable; diff --git a/server/migrations/utils/index.js b/server/migrations/utils/index.js index 7e3bf3160..abf2b4f7e 100644 --- a/server/migrations/utils/index.js +++ b/server/migrations/utils/index.js @@ -1,7 +1,9 @@ +const dumpTable = require('./dumpTable'); const recalculateMetrics = require('./recalculateMetrics'); const regenerateResultsAndRecalculateHashes = require('./regenerateResultsAndRecalculateHashes'); module.exports = { + dumpTable, recalculateMetrics, regenerateResultsAndRecalculateHashes }; diff --git a/server/migrations/utils/recalculateMetrics.js b/server/migrations/utils/recalculateMetrics.js index 7267f3e67..d2a4c444d 100644 --- a/server/migrations/utils/recalculateMetrics.js +++ b/server/migrations/utils/recalculateMetrics.js @@ -19,7 +19,10 @@ const recalculateMetrics = async (queryInterface, transaction) => { const context = getGraphQLContext({ req: { transaction } }); const testPlanReports = await queryInterface.sequelize.query( - `SELECT id, metrics FROM "TestPlanReport"`, + `select distinct on ("TestPlanReport".id) "TestPlanReport".id, metrics + from "TestPlanReport" + join public."TestPlanRun" testPlanRun on "TestPlanReport".id = testPlanRun."testPlanReportId" + where jsonb_array_length(testPlanRun."testResults") > 0;`, { type: Sequelize.QueryTypes.SELECT, transaction From e4fbb0f9ac3ba1e4e1966765f046c500779464c6 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 10:36:44 -0400 Subject: [PATCH 06/10] Update flatten migration script --- ...0710212012-flattenMigrationsPre20240710.js | 25 --- .../20240801143458-flattenMigrations.js | 16 ++ .../{ => dumps}/pg_dump_20240710.sql | 202 +----------------- 3 files changed, 25 insertions(+), 218 deletions(-) delete mode 100644 server/migrations/20240710212012-flattenMigrationsPre20240710.js create mode 100644 server/migrations/20240801143458-flattenMigrations.js rename server/migrations/{ => dumps}/pg_dump_20240710.sql (68%) diff --git a/server/migrations/20240710212012-flattenMigrationsPre20240710.js b/server/migrations/20240710212012-flattenMigrationsPre20240710.js deleted file mode 100644 index 9332fbee9..000000000 --- a/server/migrations/20240710212012-flattenMigrationsPre20240710.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface) { - const sqlFilePath = path.join(__dirname, 'pg_dump_20240710.sql'); - const sql = fs.readFileSync(sqlFilePath, 'utf-8'); - - return queryInterface.sequelize.query(sql); - - // return queryInterface.sequelize.transaction(() => { - // return Promise.all([ - // Promise.resolve() - // .then(() => - // fs.readFileSync(__dirname + '/pg_dump_20240710.sql', 'utf-8') - // ) - // .then(sql => queryInterface.sequelize.query(sql)) - // ]); - // }); - }, - async down() {} -}; diff --git a/server/migrations/20240801143458-flattenMigrations.js b/server/migrations/20240801143458-flattenMigrations.js new file mode 100644 index 000000000..fc161aa5c --- /dev/null +++ b/server/migrations/20240801143458-flattenMigrations.js @@ -0,0 +1,16 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + await queryInterface.sequelize.query(`DELETE FROM "SequelizeMeta"`); + + const sqlFilePath = path.join(__dirname, 'dumps', 'pg_dump_20240710.sql'); + const sql = fs.readFileSync(sqlFilePath, 'utf-8'); + await queryInterface.sequelize.query(sql); + }, + async down() {} +}; diff --git a/server/migrations/pg_dump_20240710.sql b/server/migrations/dumps/pg_dump_20240710.sql similarity index 68% rename from server/migrations/pg_dump_20240710.sql rename to server/migrations/dumps/pg_dump_20240710.sql index d90d58234..623cb5639 100644 --- a/server/migrations/pg_dump_20240710.sql +++ b/server/migrations/dumps/pg_dump_20240710.sql @@ -2,15 +2,18 @@ -- PostgreSQL database dump -- --- Dumped from database version 14.12 (Homebrew) --- Dumped by pg_dump version 14.12 (Homebrew) +-- Dumped from database version 14.12 (Homebrew) but modified manually to support Postgres 11 and the flattening of the +-- tables' structures from previous migrations SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); + +-- Creates issues with the SequelizeMeta table +-- SELECT pg_catalog.set_config('search_path', '', false); + SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; @@ -18,7 +21,8 @@ SET row_security = off; SET default_tablespace = ''; -SET default_table_access_method = heap; +-- Prevents import into Postgres 11 database +-- SET default_table_access_method = heap; -- -- Name: At; Type: TABLE; Schema: public; Owner: atr @@ -55,7 +59,7 @@ CREATE TABLE IF NOT EXISTS public."AtVersion" ( "atId" integer NOT NULL, name text NOT NULL, id integer NOT NULL, - "releasedAt" timestamp with time zone DEFAULT '2024-07-29 11:43:34.459-04'::timestamp with time zone NOT NULL + "releasedAt" timestamp with time zone DEFAULT (now() at time zone 'utc') NOT NULL ); @@ -238,17 +242,6 @@ CREATE TABLE IF NOT EXISTS public."Role" ( ALTER TABLE public."Role" OWNER TO atr; --- --- Name: SequelizeMeta; Type: TABLE; Schema: public; Owner: atr --- - -CREATE TABLE IF NOT EXISTS public."SequelizeMeta" ( - name character varying(255) NOT NULL -); - - -ALTER TABLE public."SequelizeMeta" OWNER TO atr; - -- -- Name: TestPlan; Type: TABLE; Schema: public; Owner: atr -- @@ -636,91 +629,6 @@ ALTER TABLE ONLY public."User" ALTER COLUMN id SET DEFAULT nextval('public."User --- --- Data for Name: SequelizeMeta; Type: TABLE DATA; Schema: public; Owner: atr --- - -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200518185559-initial-migration.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200521003201-create_table_test_issues.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200522002555-add-serialized-form-column-to-test-results.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528143617-add-run-status.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528143624-add-run-status-to-run.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200528172804-add-run-status-to-run-data-view.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915181019-create-browser-version-to-at-and-at-version.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915184800-AddActiveFlags.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200915203422-AddColumnsToTestRun.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200928035513-update-create-browser-version-to-at-version.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20200929194042-AddActiveToTestVersions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20201016203157-RemoveTestCycleModel.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20201201232332-add-links-columns-apg-examples.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210512004505-BuildNewDatabaseSchema.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210524210332-TestQueueChanges.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152335-supportNewTestQueueMutations.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152340-emptyObsoleteTables.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210601152341-removeTestPlanTargetVersionConstraints.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210809220722-UserSettings.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20210920195544-reportingBackend.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20211116172219-commandSequences.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20211118143508-testRowNumber.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427145338-alterAtVersionTable.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427192638-changeConstraintsAtVersion.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427194229-addIdConstraintAtVersion.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220427204420-changeAtVersionColumn.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220503193406-alterBrowserVersionTable.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220509140537-removeTestPlanTarget.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220712044433-changeJsonbArraysToJsonb.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220801210224-updateJawsTestInstructions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220825125643-addStatusChangeUpdateColumns.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220919142951-addVendorReviewStatusColumn.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220928162616-addViewersToTests.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220929155024-addMetricsColumn.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20220929155029-addMetricsValues.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20221116154332-updateTestPlanReportStatuses.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230329214527-removeInReviewStatusFromTestPlanReport.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230424152008-addAtBrowser.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230424152008-createTestPlanTable.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230425152008-createTestPlanColumns.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230425215656-updateTestPlanVersionTitles.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230501220810-deduplicateTestPlanVersions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230523163855-addColumnsToAtBrowsers.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230523163856-remove-OtherUnexpectedBehaviorText.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230608170853-addDateColumnsToTestPlanVersion.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230614004831-removeDateColumnsFromTestPlanReportAndRenameCandidateStatusReachedAtToApprovedAt.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230626203205-updatePhaseAndDraftPhaseReachedAtColumnsForTestPlanVersion.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230719174358-removeTestPlanReportStatus.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230823212533-addCollectionJobs.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230830225248-addMissingDeprecatedAtAndReorderPhaseChangeDates.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230927172432-addVersionStrings.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20230927230957-add-initiatedByAutomation-to-testPlanRun.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20231031162340-verifyNoSkippedTests.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20231114170315-addScreenTextAndInstructionsToAtMode.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20231129175445-updateResultsUnexpectedBehaviorImpactAndDetails.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20231219212344-recalculateV2TestHashes.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240104150500-includeAdditionalTestFormatVersionAttributes.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240111225130-includeMissingAssertionExceptions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240215220201-updateMetricsForCountingUnexpectedBehaviors.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240224173914-includeAssertionIdInTestAssertions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240229195433-modifyCollectionJobIdType.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240305205951-removeAtMode.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240311192910-removeRequiredAndOptionalPriority.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312122457-testPlanReportAtVersions.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312131258-browserVersionReleasedAt.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240312145416-updateMetricsForUsingTotalCalculation.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240313145124-addIsPrimaryColumnToTestPlanRun.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240319190618-updateCandidatePhaseReachedDates.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240321182449-addKeyColumnToAtAndBrowserTables.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240325205951-cleanupDuplicatesAndRegenerateHashes.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240401203810-fixCommandButtonPhaseChangeDate.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240404171101-addCollectionJobTestStatus.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240509102300-addIsBot.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240516195950-updateMetrics.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240522032230-fixIncorrectDeprecationDates.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240525041559-addCollectionJobSecret.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240711160607-update-may-terminology.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240715150459-resetTestPlanVersionIdToLatest.js') ON CONFLICT DO NOTHING; -INSERT INTO public."SequelizeMeta" (name) VALUES ('20240724212706-updateMetrics.js') ON CONFLICT DO NOTHING; - - -- -- Data for Name: TestPlan; Type: TABLE DATA; Schema: public; Owner: atr -- @@ -763,89 +671,6 @@ INSERT INTO public."SequelizeMeta" (name) VALUES ('20240724212706-updateMetrics. --- --- Data for Name: session; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Name: AtVersion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."AtVersion_id_seq"', 1, false); - - --- --- Name: At_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."At_id_seq"', 1, false); - - --- --- Name: BrowserVersion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."BrowserVersion_id_seq"', 1, false); - - --- --- Name: Browser_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."Browser_id_seq"', 1, false); - - --- --- Name: CollectionJobTestStatus_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."CollectionJobTestStatus_id_seq"', 1, false); - - --- --- Name: TestPlanReport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlanReport_id_seq"', 1, false); - - --- --- Name: TestPlanRun_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlanRun_id_seq"', 1, false); - - --- --- Name: TestPlan_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlan_id_seq"', 1, false); - - --- --- Name: TestPlan_id_seq1; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."TestPlan_id_seq1"', 1, false); - - --- --- Name: User_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public."User_id_seq"', 1, false); - - --- --- Name: collectionjob_id_seq; Type: SEQUENCE SET; Schema: public; Owner: atr --- - -SELECT pg_catalog.setval('public.collectionjob_id_seq', 1, true); - - -- -- Name: AtVersion AtVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- @@ -927,15 +752,6 @@ ALTER TABLE ONLY public."Role" ADD CONSTRAINT "Role_pkey" PRIMARY KEY (name); --- --- Name: SequelizeMeta SequelizeMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: atr --- - -ALTER TABLE public."SequelizeMeta" DROP CONSTRAINT IF EXISTS "SequelizeMeta_pkey" CASCADE; -ALTER TABLE ONLY public."SequelizeMeta" - ADD CONSTRAINT "SequelizeMeta_pkey" PRIMARY KEY (name); - - -- -- Name: TestPlanReport TestPlanReport_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- From 0f74036e2aabe7765eb92b8b3071f157ac982000 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 11:30:46 -0400 Subject: [PATCH 07/10] Update flattened migration dump --- .../20240801143458-flattenMigrations.js | 2 +- ...dump_20240710.sql => pg_dump_20240801.sql} | 144 ++++++------------ 2 files changed, 49 insertions(+), 97 deletions(-) rename server/migrations/dumps/{pg_dump_20240710.sql => pg_dump_20240801.sql} (74%) diff --git a/server/migrations/20240801143458-flattenMigrations.js b/server/migrations/20240801143458-flattenMigrations.js index fc161aa5c..43a82c735 100644 --- a/server/migrations/20240801143458-flattenMigrations.js +++ b/server/migrations/20240801143458-flattenMigrations.js @@ -8,7 +8,7 @@ module.exports = { async up(queryInterface) { await queryInterface.sequelize.query(`DELETE FROM "SequelizeMeta"`); - const sqlFilePath = path.join(__dirname, 'dumps', 'pg_dump_20240710.sql'); + const sqlFilePath = path.join(__dirname, 'dumps', 'pg_dump_20240801.sql'); const sql = fs.readFileSync(sqlFilePath, 'utf-8'); await queryInterface.sequelize.query(sql); }, diff --git a/server/migrations/dumps/pg_dump_20240710.sql b/server/migrations/dumps/pg_dump_20240801.sql similarity index 74% rename from server/migrations/dumps/pg_dump_20240710.sql rename to server/migrations/dumps/pg_dump_20240801.sql index 623cb5639..b484305f2 100644 --- a/server/migrations/dumps/pg_dump_20240710.sql +++ b/server/migrations/dumps/pg_dump_20240801.sql @@ -24,6 +24,20 @@ SET default_tablespace = ''; -- Prevents import into Postgres 11 database -- SET default_table_access_method = heap; +create or replace function add_constraint_if_not_exists( + constraint_name TEXT, + table_name TEXT, + constraint_definition TEXT +) returns void +language plpgsql +as $$ +begin + if not exists ( select 1 from pg_constraint where conname = constraint_name ) then + execute format('ALTER TABLE ONLY public.%I ADD CONSTRAINT %I %s', table_name, constraint_name, constraint_definition); + end if; +end; +$$; + -- -- Name: At; Type: TABLE; Schema: public; Owner: atr -- @@ -675,171 +689,133 @@ ALTER TABLE ONLY public."User" ALTER COLUMN id SET DEFAULT nextval('public."User -- Name: AtVersion AtVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_pkey" CASCADE; -ALTER TABLE ONLY public."AtVersion" - ADD CONSTRAINT "AtVersion_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('AtVersion_pkey', 'AtVersion', 'PRIMARY KEY (id)'); -- -- Name: At At_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."At" DROP CONSTRAINT IF EXISTS "At_pkey" CASCADE; -ALTER TABLE ONLY public."At" - ADD CONSTRAINT "At_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('At_pkey', 'At', 'PRIMARY KEY (id)'); -- -- Name: BrowserVersion BrowserVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_pkey" CASCADE; -ALTER TABLE ONLY public."BrowserVersion" - ADD CONSTRAINT "BrowserVersion_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('BrowserVersion_pkey', 'BrowserVersion', 'PRIMARY KEY (id)'); -- -- Name: Browser Browser_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."Browser" DROP CONSTRAINT IF EXISTS "Browser_pkey" CASCADE; -ALTER TABLE ONLY public."Browser" - ADD CONSTRAINT "Browser_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('Browser_pkey', 'Browser', 'PRIMARY KEY (id)'); -- -- Name: CollectionJobTestStatus CollectionJobTestStatus_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJobTestStatus_pkey" CASCADE; -ALTER TABLE ONLY public."CollectionJobTestStatus" - ADD CONSTRAINT "CollectionJobTestStatus_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('CollectionJobTestStatus_pkey', 'CollectionJobTestStatus', 'PRIMARY KEY (id)'); -- -- Name: CollectionJobTestStatus CollectionJob_Test_unique; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJob_Test_unique" CASCADE; -ALTER TABLE ONLY public."CollectionJobTestStatus" - ADD CONSTRAINT "CollectionJob_Test_unique" UNIQUE ("collectionJobId", "testId"); +SELECT add_constraint_if_not_exists('CollectionJob_Test_unique', 'CollectionJobTestStatus', 'UNIQUE ("collectionJobId", "testId")'); -- -- Name: CollectionJob CollectionJob_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_pkey" CASCADE; -ALTER TABLE ONLY public."CollectionJob" - ADD CONSTRAINT "CollectionJob_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('CollectionJob_pkey', 'CollectionJob', 'PRIMARY KEY (id)'); -- -- Name: CollectionJob CollectionJob_testPlanRunId_key; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_testPlanRunId_key" CASCADE; -ALTER TABLE ONLY public."CollectionJob" - ADD CONSTRAINT "CollectionJob_testPlanRunId_key" UNIQUE ("testPlanRunId"); +SELECT add_constraint_if_not_exists('CollectionJob_testPlanRunId_key', 'CollectionJob', 'UNIQUE ("testPlanRunId")'); -- -- Name: Role Role_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."Role" DROP CONSTRAINT IF EXISTS "Role_pkey" CASCADE; -ALTER TABLE ONLY public."Role" - ADD CONSTRAINT "Role_pkey" PRIMARY KEY (name); +SELECT add_constraint_if_not_exists('Role_pkey', 'Role', 'PRIMARY KEY (name)'); -- -- Name: TestPlanReport TestPlanReport_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_pkey" CASCADE; -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('TestPlanReport_pkey', 'TestPlanReport', 'PRIMARY KEY (id)'); -- -- Name: TestPlanRun TestPlanRun_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_pkey" CASCADE; -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('TestPlanRun_pkey', 'TestPlanRun', 'PRIMARY KEY (id)'); -- -- Name: TestPlanVersion TestPlanVersion_hashedTests_key; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlanVersion_hashedTests_key" CASCADE; -ALTER TABLE ONLY public."TestPlanVersion" - ADD CONSTRAINT "TestPlanVersion_hashedTests_key" UNIQUE ("hashedTests"); +SELECT add_constraint_if_not_exists('TestPlanVersion_hashedTests_key', 'TestPlanVersion', 'UNIQUE ("hashedTests")'); -- -- Name: TestPlanVersion TestPlan_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlan_pkey" CASCADE; -ALTER TABLE ONLY public."TestPlanVersion" - ADD CONSTRAINT "TestPlan_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('TestPlan_pkey', 'TestPlanVersion', 'PRIMARY KEY (id)'); -- -- Name: TestPlan TestPlan_pkey1; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlan" DROP CONSTRAINT IF EXISTS "TestPlan_pkey1" CASCADE; -ALTER TABLE ONLY public."TestPlan" - ADD CONSTRAINT "TestPlan_pkey1" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('TestPlan_pkey1', 'TestPlan', 'PRIMARY KEY (id)'); -- -- Name: UserRoles UserRoles_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_pkey" CASCADE; -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_pkey" PRIMARY KEY ("userId", "roleName"); +SELECT add_constraint_if_not_exists('UserRoles_pkey', 'UserRoles', 'PRIMARY KEY ("userId", "roleName")'); -- -- Name: User User_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."User" DROP CONSTRAINT IF EXISTS "User_pkey" CASCADE; -ALTER TABLE ONLY public."User" - ADD CONSTRAINT "User_pkey" PRIMARY KEY (id); +SELECT add_constraint_if_not_exists('User_pkey', 'User', 'PRIMARY KEY (id)'); -- -- Name: User User_username_key; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."User" DROP CONSTRAINT IF EXISTS "User_username_key" CASCADE; -ALTER TABLE ONLY public."User" - ADD CONSTRAINT "User_username_key" UNIQUE (username); +SELECT add_constraint_if_not_exists('User_username_key', 'User', 'UNIQUE (username)'); -- -- Name: session session_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public.session DROP CONSTRAINT IF EXISTS session_pkey CASCADE; -ALTER TABLE ONLY public.session - ADD CONSTRAINT session_pkey PRIMARY KEY (sid); +SELECT add_constraint_if_not_exists('session_pkey', 'session', 'PRIMARY KEY (sid)'); -- -- Name: TestPlanVersion uniqueVersionStringByDirectory; Type: CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "uniqueVersionStringByDirectory" CASCADE; -ALTER TABLE ONLY public."TestPlanVersion" - ADD CONSTRAINT "uniqueVersionStringByDirectory" UNIQUE (directory, "versionString"); +SELECT add_constraint_if_not_exists('uniqueVersionStringByDirectory', 'TestPlanVersion', 'UNIQUE (directory, "versionString")'); -- @@ -853,118 +829,94 @@ CREATE INDEX IF NOT EXISTS "IDX_session_expire" ON public.session USING btree (e -- Name: AtBrowsers AtBrowsers_atId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."AtBrowsers" DROP CONSTRAINT IF EXISTS "AtBrowsers_atId_fkey" CASCADE; -ALTER TABLE ONLY public."AtBrowsers" - ADD CONSTRAINT "AtBrowsers_atId_fkey" FOREIGN KEY ("atId") REFERENCES public."At"(id); +SELECT add_constraint_if_not_exists('AtBrowsers_atId_fkey', 'AtBrowsers', 'FOREIGN KEY ("atId") REFERENCES public."At"(id)'); -- -- Name: AtBrowsers AtBrowsers_browserId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."AtBrowsers" DROP CONSTRAINT IF EXISTS "AtBrowsers_browserId_fkey" CASCADE; -ALTER TABLE ONLY public."AtBrowsers" - ADD CONSTRAINT "AtBrowsers_browserId_fkey" FOREIGN KEY ("browserId") REFERENCES public."Browser"(id); +SELECT add_constraint_if_not_exists('AtBrowsers_browserId_fkey', 'AtBrowsers', 'FOREIGN KEY ("browserId") REFERENCES public."Browser"(id)'); -- -- Name: AtVersion AtVersion_at_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."AtVersion" DROP CONSTRAINT IF EXISTS "AtVersion_at_fkey" CASCADE; -ALTER TABLE ONLY public."AtVersion" - ADD CONSTRAINT "AtVersion_at_fkey" FOREIGN KEY ("atId") REFERENCES public."At"(id) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('AtVersion_at_fkey', 'AtVersion', 'FOREIGN KEY ("atId") REFERENCES public."At"(id) ON UPDATE CASCADE ON DELETE CASCADE'); -- -- Name: BrowserVersion BrowserVersion_browser_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."BrowserVersion" DROP CONSTRAINT IF EXISTS "BrowserVersion_browser_fkey" CASCADE; -ALTER TABLE ONLY public."BrowserVersion" - ADD CONSTRAINT "BrowserVersion_browser_fkey" FOREIGN KEY ("browserId") REFERENCES public."Browser"(id) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('BrowserVersion_browser_fkey', 'BrowserVersion', 'FOREIGN KEY ("browserId") REFERENCES public."Browser"(id) ON UPDATE CASCADE ON DELETE CASCADE'); -- -- Name: CollectionJobTestStatus CollectionJobTestStatus_collectionJobId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJobTestStatus" DROP CONSTRAINT IF EXISTS "CollectionJobTestStatus_collectionJobId_fkey" CASCADE; -ALTER TABLE ONLY public."CollectionJobTestStatus" - ADD CONSTRAINT "CollectionJobTestStatus_collectionJobId_fkey" FOREIGN KEY ("collectionJobId") REFERENCES public."CollectionJob"(id) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('CollectionJobTestStatus_collectionJobId_fkey', 'CollectionJobTestStatus', 'FOREIGN KEY ("collectionJobId") REFERENCES public."CollectionJob"(id) ON UPDATE CASCADE ON DELETE CASCADE'); -- -- Name: CollectionJob CollectionJob_testPlanRunId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."CollectionJob" DROP CONSTRAINT IF EXISTS "CollectionJob_testPlanRunId_fkey" CASCADE; -ALTER TABLE ONLY public."CollectionJob" - ADD CONSTRAINT "CollectionJob_testPlanRunId_fkey" FOREIGN KEY ("testPlanRunId") REFERENCES public."TestPlanRun"(id) ON DELETE SET NULL; +SELECT add_constraint_if_not_exists('CollectionJob_testPlanRunId_fkey', 'CollectionJob', 'FOREIGN KEY ("testPlanRunId") REFERENCES public."TestPlanRun"(id) ON DELETE SET NULL'); -- -- Name: TestPlanReport TestPlanReport_testPlanId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlanId_fkey" CASCADE; -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_testPlanId_fkey" FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id); +SELECT add_constraint_if_not_exists('TestPlanReport_testPlanId_fkey', 'TestPlanReport', 'FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id)'); -- -- Name: TestPlanReport TestPlanReport_testPlan_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanReport" DROP CONSTRAINT IF EXISTS "TestPlanReport_testPlan_fkey" CASCADE; -ALTER TABLE ONLY public."TestPlanReport" - ADD CONSTRAINT "TestPlanReport_testPlan_fkey" FOREIGN KEY ("testPlanVersionId") REFERENCES public."TestPlanVersion"(id) ON UPDATE CASCADE; +SELECT add_constraint_if_not_exists('TestPlanReport_testPlan_fkey', 'TestPlanReport', 'FOREIGN KEY ("testPlanVersionId") REFERENCES public."TestPlanVersion"(id) ON UPDATE CASCADE'); -- -- Name: TestPlanRun TestPlanRun_testPlanReport_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_testPlanReport_fkey" CASCADE; -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_testPlanReport_fkey" FOREIGN KEY ("testPlanReportId") REFERENCES public."TestPlanReport"(id) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('TestPlanRun_testPlanReport_fkey', 'TestPlanRun', 'FOREIGN KEY ("testPlanReportId") REFERENCES public."TestPlanReport"(id) ON UPDATE CASCADE ON DELETE CASCADE'); -- -- Name: TestPlanRun TestPlanRun_tester_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanRun" DROP CONSTRAINT IF EXISTS "TestPlanRun_tester_fkey" CASCADE; -ALTER TABLE ONLY public."TestPlanRun" - ADD CONSTRAINT "TestPlanRun_tester_fkey" FOREIGN KEY ("testerUserId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE SET NULL; +SELECT add_constraint_if_not_exists('TestPlanRun_tester_fkey', 'TestPlanRun', 'FOREIGN KEY ("testerUserId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE SET NULL'); -- -- Name: TestPlanVersion TestPlanVersion_testPlanId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."TestPlanVersion" DROP CONSTRAINT IF EXISTS "TestPlanVersion_testPlanId_fkey" CASCADE; -ALTER TABLE ONLY public."TestPlanVersion" - ADD CONSTRAINT "TestPlanVersion_testPlanId_fkey" FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id); +SELECT add_constraint_if_not_exists('TestPlanVersion_testPlanId_fkey', 'TestPlanVersion', 'FOREIGN KEY ("testPlanId") REFERENCES public."TestPlan"(id)'); -- -- Name: UserRoles UserRoles_roleName_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_roleName_fkey" CASCADE; -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_roleName_fkey" FOREIGN KEY ("roleName") REFERENCES public."Role"(name) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('UserRoles_roleName_fkey', 'UserRoles', 'FOREIGN KEY ("roleName") REFERENCES public."Role"(name) ON UPDATE CASCADE ON DELETE CASCADE'); -- -- Name: UserRoles UserRoles_userId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atr -- -ALTER TABLE public."UserRoles" DROP CONSTRAINT IF EXISTS "UserRoles_userId_fkey" CASCADE; -ALTER TABLE ONLY public."UserRoles" - ADD CONSTRAINT "UserRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE CASCADE; +SELECT add_constraint_if_not_exists('UserRoles_userId_fkey', 'UserRoles', 'FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE CASCADE'); + +DROP FUNCTION add_constraint_if_not_exists(TEXT, TEXT, TEXT); -- -- PostgreSQL database dump complete From fd7bb7724ee5b3c602f82c19b184aa51f4e7de08 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Thu, 1 Aug 2024 11:53:11 -0400 Subject: [PATCH 08/10] Update dumpTable path --- server/migrations/utils/dumpTable.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/migrations/utils/dumpTable.js b/server/migrations/utils/dumpTable.js index c4c597f4f..b91775f0e 100644 --- a/server/migrations/utils/dumpTable.js +++ b/server/migrations/utils/dumpTable.js @@ -1,4 +1,5 @@ const { exec } = require('child_process'); +const path = require('path'); /** * Used to dump a table in case a significantly destructive behavior is to be @@ -10,10 +11,12 @@ const { exec } = require('child_process'); */ const dumpTable = async tableName => { try { + const dumpFilePath = path.resolve( + `${__dirname}/../dumps/pg_dump_${tableName}_${new Date().getTime()}.sql` + ); + await exec( - `pg_dump -t '"${tableName}"' ${ - process.env.PGDATABASE - } > ${__dirname}/dumps/pg_dump_${tableName}_${new Date().getTime()}.sql` + `pg_dump -t '"${tableName}"' ${process.env.PGDATABASE} --inserts > ${dumpFilePath}` ); } catch (err) { console.error(`Error dumping ${tableName}:${err}`); From f4820e583b904595f0a48c306eed49304009d78c Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Mon, 5 Aug 2024 09:01:10 -0400 Subject: [PATCH 09/10] Update sql dump --- .gitignore | 2 + .../20240801143458-flattenMigrations.js | 62 +++++++++- ...> pg_dump_flatten_migrations_20240801.sql} | 115 +++--------------- server/migrations/utils/dumpDatabase.js | 22 ++++ server/migrations/utils/dumpTable.js | 3 +- server/migrations/utils/index.js | 2 + 6 files changed, 98 insertions(+), 108 deletions(-) rename server/migrations/dumps/{pg_dump_20240801.sql => pg_dump_flatten_migrations_20240801.sql} (93%) create mode 100644 server/migrations/utils/dumpDatabase.js diff --git a/.gitignore b/.gitignore index 9ba4c2283..2ec1b6e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,8 @@ deploy/provision.retry # Migration generated files server/migrations/pg_dump_test_plan_target.sql server/migrations/test_plan_target_id.csv +server/migrations/dumps/dumpDatabase_*.sql +server/migrations/dumps/dumpTable_*.sql # Private Key files (installed by deploy) jwt-signing-key.pem diff --git a/server/migrations/20240801143458-flattenMigrations.js b/server/migrations/20240801143458-flattenMigrations.js index 43a82c735..65895ec63 100644 --- a/server/migrations/20240801143458-flattenMigrations.js +++ b/server/migrations/20240801143458-flattenMigrations.js @@ -2,15 +2,67 @@ const fs = require('fs'); const path = require('path'); +const { dumpDatabase } = require('./utils'); /** @type {import('sequelize-cli').Migration} */ module.exports = { - async up(queryInterface) { - await queryInterface.sequelize.query(`DELETE FROM "SequelizeMeta"`); + async up(queryInterface, Sequelize) { + return queryInterface.sequelize.transaction(async transaction => { + // Purge sequelize tracked migrations + await queryInterface.sequelize.query(`delete + from "SequelizeMeta"`); - const sqlFilePath = path.join(__dirname, 'dumps', 'pg_dump_20240801.sql'); - const sql = fs.readFileSync(sqlFilePath, 'utf-8'); - await queryInterface.sequelize.query(sql); + // Backup current database + await dumpDatabase(); + + // Confirm structure of tables, keys and sequences are created + const sqlFilePath = path.join( + __dirname, + 'dumps', + 'pg_dump_flatten_migrations_20240801.sql' + ); + const sql = fs.readFileSync(sqlFilePath, 'utf-8'); + await queryInterface.sequelize.query(sql); + + // Preserve 'next' sequence values (especially important for how the + // CollectionJob sequence is handled across the testing/prod environments + const tableWithSequences = [ + '"At"', + '"AtVersion"', + '"Browser"', + '"BrowserVersion"', + '"CollectionJob"', + '"CollectionJobTestStatus"', + '"TestPlan"', + '"TestPlanReport"', + '"TestPlanRun"', + '"TestPlanVersion"', + '"User"' + ]; + + for (const tableWithSequence of tableWithSequences) { + const [latest] = await queryInterface.sequelize.query( + `select id + from ${tableWithSequence} + order by id desc + limit 1`, + { + type: Sequelize.QueryTypes.SELECT, + transaction + } + ); + + if (latest) { + await queryInterface.sequelize.query( + `SELECT setval(pg_get_serial_sequence('${tableWithSequence}', 'id'), :currentSequenceValue)`, + { + replacements: { currentSequenceValue: latest.id }, + transaction + } + ); + } + } + }); }, async down() {} }; diff --git a/server/migrations/dumps/pg_dump_20240801.sql b/server/migrations/dumps/pg_dump_flatten_migrations_20240801.sql similarity index 93% rename from server/migrations/dumps/pg_dump_20240801.sql rename to server/migrations/dumps/pg_dump_flatten_migrations_20240801.sql index b484305f2..ec9ae40ce 100644 --- a/server/migrations/dumps/pg_dump_20240801.sql +++ b/server/migrations/dumps/pg_dump_flatten_migrations_20240801.sql @@ -5,21 +5,21 @@ -- Dumped from database version 14.12 (Homebrew) but modified manually to support Postgres 11 and the flattening of the -- tables' structures from previous migrations -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; +-- SET statement_timeout = 0; +-- SET lock_timeout = 0; +-- SET idle_in_transaction_session_timeout = 0; +-- SET client_encoding = 'UTF8'; +-- SET standard_conforming_strings = on; -- Creates issues with the SequelizeMeta table -- SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; +-- SET check_function_bodies = false; +-- SET xmloption = content; +-- SET client_min_messages = warning; +-- SET row_security = off; -SET default_tablespace = ''; +-- SET default_tablespace = ''; -- Prevents import into Postgres 11 database -- SET default_table_access_method = heap; @@ -595,96 +595,6 @@ ALTER TABLE ONLY public."TestPlanVersion" ALTER COLUMN id SET DEFAULT nextval('p ALTER TABLE ONLY public."User" ALTER COLUMN id SET DEFAULT nextval('public."User_id_seq"'::regclass); --- --- Data for Name: At; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: AtBrowsers; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: AtVersion; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: Browser; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: BrowserVersion; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: CollectionJob; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: CollectionJobTestStatus; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: Role; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlan; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanReport; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanRun; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: TestPlanVersion; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: User; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: UserAts; Type: TABLE DATA; Schema: public; Owner: atr --- - - - --- --- Data for Name: UserRoles; Type: TABLE DATA; Schema: public; Owner: atr --- - - - -- -- Name: AtVersion AtVersion_pkey; Type: CONSTRAINT; Schema: public; Owner: atr -- @@ -915,9 +825,12 @@ SELECT add_constraint_if_not_exists('UserRoles_roleName_fkey', 'UserRoles', 'FOR SELECT add_constraint_if_not_exists('UserRoles_userId_fkey', 'UserRoles', 'FOREIGN KEY ("userId") REFERENCES public."User"(id) ON UPDATE CASCADE ON DELETE CASCADE'); - +-- Remove the function as it won't be used again DROP FUNCTION add_constraint_if_not_exists(TEXT, TEXT, TEXT); +-- Specially handle next sequence value for CollectionJob due to how testing is done +SELECT pg_catalog.setval('public.collectionjob_id_seq', 1, true); + -- -- PostgreSQL database dump complete -- diff --git a/server/migrations/utils/dumpDatabase.js b/server/migrations/utils/dumpDatabase.js new file mode 100644 index 000000000..3cdb8a87b --- /dev/null +++ b/server/migrations/utils/dumpDatabase.js @@ -0,0 +1,22 @@ +const { exec } = require('child_process'); +const path = require('path'); + +/** + * Used to dump the database in case a significantly destructive behavior is to + * be done. This should make running a down migration possible if required. + * + * @returns {Promise} + */ +const dumpDatabase = async () => { + try { + const dumpFilePath = path.resolve( + `${__dirname}/../dumps/dumpDatabase_${new Date().getTime()}.sql` + ); + + await exec(`pg_dump ${process.env.PGDATABASE} --inserts > ${dumpFilePath}`); + } catch (err) { + console.error(`Error dumping ${process.env.PGDATABASE}:${err}`); + } +}; + +module.exports = dumpDatabase; diff --git a/server/migrations/utils/dumpTable.js b/server/migrations/utils/dumpTable.js index b91775f0e..68bff3530 100644 --- a/server/migrations/utils/dumpTable.js +++ b/server/migrations/utils/dumpTable.js @@ -5,14 +5,13 @@ const path = require('path'); * Used to dump a table in case a significantly destructive behavior is to be * done. This should make running a down migration possible if required. * - * Ideally, also add "server/migrations/dumps/" to /.gitignore * @param tableName * @returns {Promise} */ const dumpTable = async tableName => { try { const dumpFilePath = path.resolve( - `${__dirname}/../dumps/pg_dump_${tableName}_${new Date().getTime()}.sql` + `${__dirname}/../dumps/dumpTable_${tableName}_${new Date().getTime()}.sql` ); await exec( diff --git a/server/migrations/utils/index.js b/server/migrations/utils/index.js index abf2b4f7e..344df864e 100644 --- a/server/migrations/utils/index.js +++ b/server/migrations/utils/index.js @@ -1,8 +1,10 @@ +const dumpDatabase = require('./dumpDatabase'); const dumpTable = require('./dumpTable'); const recalculateMetrics = require('./recalculateMetrics'); const regenerateResultsAndRecalculateHashes = require('./regenerateResultsAndRecalculateHashes'); module.exports = { + dumpDatabase, dumpTable, recalculateMetrics, regenerateResultsAndRecalculateHashes From 72861c2854fa6867767309b03ae27b8255504628 Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Mon, 5 Aug 2024 15:47:40 -0400 Subject: [PATCH 10/10] Throw error if pg_dump failed to run --- server/migrations/utils/dumpDatabase.js | 3 +-- server/migrations/utils/dumpTable.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/migrations/utils/dumpDatabase.js b/server/migrations/utils/dumpDatabase.js index 3cdb8a87b..6fdc582ef 100644 --- a/server/migrations/utils/dumpDatabase.js +++ b/server/migrations/utils/dumpDatabase.js @@ -12,10 +12,9 @@ const dumpDatabase = async () => { const dumpFilePath = path.resolve( `${__dirname}/../dumps/dumpDatabase_${new Date().getTime()}.sql` ); - await exec(`pg_dump ${process.env.PGDATABASE} --inserts > ${dumpFilePath}`); } catch (err) { - console.error(`Error dumping ${process.env.PGDATABASE}:${err}`); + throw new Error(`Error dumping ${process.env.PGDATABASE}:${err.message}`); } }; diff --git a/server/migrations/utils/dumpTable.js b/server/migrations/utils/dumpTable.js index 68bff3530..d8a3f7900 100644 --- a/server/migrations/utils/dumpTable.js +++ b/server/migrations/utils/dumpTable.js @@ -13,12 +13,11 @@ const dumpTable = async tableName => { const dumpFilePath = path.resolve( `${__dirname}/../dumps/dumpTable_${tableName}_${new Date().getTime()}.sql` ); - await exec( `pg_dump -t '"${tableName}"' ${process.env.PGDATABASE} --inserts > ${dumpFilePath}` ); } catch (err) { - console.error(`Error dumping ${tableName}:${err}`); + throw new Error(`Error dumping ${tableName}:${err.message}`); } };