From 767ca38e1fb2b0f6cab642b43758c32e08460509 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Mon, 14 Aug 2023 10:46:59 +0200 Subject: [PATCH 01/20] add ParticlesPhysDataDefinition --- app/lib/database/models/ParticilesPhysData.js | 43 +++++++++++++++++++ app/lib/database/models/index.js | 2 + 2 files changed, 45 insertions(+) create mode 100644 app/lib/database/models/ParticilesPhysData.js diff --git a/app/lib/database/models/ParticilesPhysData.js b/app/lib/database/models/ParticilesPhysData.js new file mode 100644 index 000000000..478f3afea --- /dev/null +++ b/app/lib/database/models/ParticilesPhysData.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const Sequelize = require('sequelize'); + +module.exports = (sequelize) => { + const ParticlesPhysData = sequelize.define('ParticlesPhysData', { + name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + fullName: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + A: { + type: Sequelize.SMALLINT, + allowNull: false, + }, + Z: { + type: Sequelize.SMALLINT, + allowNull: false, + unique: true, + }, + + }, { timestamps: false, tableName: 'particles_phys_data' }); + + ParticlesPhysData.associate = () => {}; + + return ParticlesPhysData; +}; diff --git a/app/lib/database/models/index.js b/app/lib/database/models/index.js index d05faef97..55d9f017e 100644 --- a/app/lib/database/models/index.js +++ b/app/lib/database/models/index.js @@ -23,6 +23,7 @@ const RunDetectors = require('./RunDetectors.js'); const QualityControlFlag = require('./QualitControlFlag.js'); const QualityControlFlagVerification = require('./QualityControlFlagVerification.js'); const FlagType = require('./FlagType.js'); +const ParticlesPhysData = require('./ParticilesPhysData.js'); /** * @@ -41,6 +42,7 @@ const modelsFactory = (sequelize) => { QualityControlFlag, QualityControlFlagVerification, FlagType, + ParticlesPhysData, }; models = Object.entries(models).map(([modelName, model]) => [modelName, model(sequelize)]); // instantiate models models.forEach(([_, modelInstance]) => modelInstance.associate?.(sequelize.models)); // associate models From 5f19841347d649aa308045ab893708511c754920 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Mon, 14 Aug 2023 10:47:46 +0200 Subject: [PATCH 02/20] add MetaData model --- app/lib/database/models/Meta.js | 35 ++++++++++++++++++++++++++++++++ app/lib/database/models/index.js | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 app/lib/database/models/Meta.js diff --git a/app/lib/database/models/Meta.js b/app/lib/database/models/Meta.js new file mode 100644 index 000000000..82cf94d4f --- /dev/null +++ b/app/lib/database/models/Meta.js @@ -0,0 +1,35 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const Sequelize = require('sequelize'); + +module.exports = (sequelize) => { + const MetaData = sequelize.define('MetaData', { + name: { + primaryKey: true, + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + val: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + }, + + }, { timestamps: true, tableName: 'meta' }); + + MetaData.associate = () => {}; + + return MetaData; +}; diff --git a/app/lib/database/models/index.js b/app/lib/database/models/index.js index 55d9f017e..2930b3b19 100644 --- a/app/lib/database/models/index.js +++ b/app/lib/database/models/index.js @@ -24,6 +24,7 @@ const QualityControlFlag = require('./QualitControlFlag.js'); const QualityControlFlagVerification = require('./QualityControlFlagVerification.js'); const FlagType = require('./FlagType.js'); const ParticlesPhysData = require('./ParticilesPhysData.js'); +const MetaData = require('./Meta.js'); /** * @@ -43,6 +44,7 @@ const modelsFactory = (sequelize) => { QualityControlFlagVerification, FlagType, ParticlesPhysData, + MetaData, }; models = Object.entries(models).map(([modelName, model]) => [modelName, model(sequelize)]); // instantiate models models.forEach(([_, modelInstance]) => modelInstance.associate?.(sequelize.models)); // associate models From 342d05c1431a1bd0b237f7d99c206596fbf275bf Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:16:54 +0200 Subject: [PATCH 03/20] add .seqelizerc --- .sequelizerc | 9 +++++++++ app/config/database.js | 28 ++++++++++++++++++++++++++++ app/config/index.js | 2 +- docker/docker-compose-volumes.yml | 4 ++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .sequelizerc create mode 100644 app/config/database.js diff --git a/.sequelizerc b/.sequelizerc new file mode 100644 index 000000000..b0312fdc5 --- /dev/null +++ b/.sequelizerc @@ -0,0 +1,9 @@ + +const path = require('path'); + +module.exports = { + 'config': path.resolve('app', 'config', 'database.js'), + 'models-path': path.resolve('app', 'lib', 'database', 'models'), + 'seeders-path': path.resolve('app', 'lib', 'database', 'seeders'), + 'migrations-path': path.resolve('app', 'lib', 'database', 'migrations') +}; diff --git a/app/config/database.js b/app/config/database.js new file mode 100644 index 000000000..79e0e733d --- /dev/null +++ b/app/config/database.js @@ -0,0 +1,28 @@ +/** + * @license + * Copyright 2019-2020 CERN and copyright holders of ALICE O2. + * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. + * All rights not expressly granted are reserved. + * + * This software is distributed under the terms of the GNU General Public + * License v3 (GPL Version 3), copied verbatim in the file "COPYING". + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ +const { ResProvider } = require('../lib/utils'); + +const legacyConfig = ResProvider.database(); + +const config = { ...legacyConfig, + username: legacyConfig.user, // TEMPORARILY + logging: legacyConfig.logging ? this.logger.debug.bind(this.logger) : false, + dialect: 'postgres', + define: { + underscored: true, + schema: this.schema, + }, +}; + +module.exports = config; diff --git a/app/config/index.js b/app/config/index.js index 382211f21..96a6ac640 100644 --- a/app/config/index.js +++ b/app/config/index.js @@ -21,7 +21,7 @@ module.exports = Object.freeze({ // App config winston: ResProvider.winston(), - database: ResProvider.database(), + database: require('./database.js'), syncTaskAtStart: ResProvider.envOrDef('RCT_SYNC_TASK_AT_START', false, Boolean), rctData: require('./rct-data'), public: require('./public.js'), diff --git a/docker/docker-compose-volumes.yml b/docker/docker-compose-volumes.yml index a61aac987..e975dce62 100644 --- a/docker/docker-compose-volumes.yml +++ b/docker/docker-compose-volumes.yml @@ -22,6 +22,10 @@ services: read_only: true source: ./package-lock.json target: /opt/RunConditionTable/package-lock.json + - type: bind + read_only: true + source: ./.sequelizerc + target: /opt/RunConditionTable/.sequelizerc database: volumes: From 80b49ec9b1222c0b0ab6fca62b199829e8f7c5b3 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:27:52 +0200 Subject: [PATCH 04/20] grant rct-psermission necessay for running sequelize migration --- database/setup-db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/setup-db.sh b/database/setup-db.sh index aa40dff49..3b74307e7 100755 --- a/database/setup-db.sh +++ b/database/setup-db.sh @@ -159,7 +159,7 @@ drop() { create_main() { psql -c "set password_encryption='scram-sha-256'; CREATE USER \"$RCT_DB_USERNAME\" WITH ENCRYPTED PASSWORD '$RCT_DB_PASSWORD';" psql -c "CREATE DATABASE \"$RCT_DB_NAME\"" - psql -d $RCT_DB_NAME -a -f $CREATE_TABLES_SQL + psql -U $RCT_DB_USERNAME -d $RCT_DB_NAME -a -f $CREATE_TABLES_SQL } create_other() { From 947f2336504c00281a29e912d6a0f43e588aecff Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:41:11 +0200 Subject: [PATCH 05/20] name error, removed legacy code for creating tables --- app/lib/database/models/ParticilesPhysData.js | 3 ++- database/setup-db.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/database/models/ParticilesPhysData.js b/app/lib/database/models/ParticilesPhysData.js index 478f3afea..d7f7aef94 100644 --- a/app/lib/database/models/ParticilesPhysData.js +++ b/app/lib/database/models/ParticilesPhysData.js @@ -35,7 +35,8 @@ module.exports = (sequelize) => { unique: true, }, - }, { timestamps: false, tableName: 'particles_phys_data' }); + }, { timestamps: false, tableName: 'particle_phys_data' }); + ParticlesPhysData.associate = () => {}; diff --git a/database/setup-db.sh b/database/setup-db.sh index 3b74307e7..de934daeb 100755 --- a/database/setup-db.sh +++ b/database/setup-db.sh @@ -159,7 +159,6 @@ drop() { create_main() { psql -c "set password_encryption='scram-sha-256'; CREATE USER \"$RCT_DB_USERNAME\" WITH ENCRYPTED PASSWORD '$RCT_DB_PASSWORD';" psql -c "CREATE DATABASE \"$RCT_DB_NAME\"" - psql -U $RCT_DB_USERNAME -d $RCT_DB_NAME -a -f $CREATE_TABLES_SQL } create_other() { From 3e4c4919f16760fa0431ae5652c8eef1daef7dcf Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:53:48 +0200 Subject: [PATCH 06/20] add migration files --- .../20230816130100-create-beams_dictionary.js | 34 ++++++++ .../20230816130200-create-periods.js | 45 ++++++++++ .../migrations/20230816130300-create-runs.js | 57 +++++++++++++ ...30816130400-create-detectors_subsystems.js | 34 ++++++++ .../20230816130500-create-data_passes.js | 54 ++++++++++++ ...20230816130600-create-simulation_passes.js | 49 +++++++++++ .../20230816130700-create-runs_detectors.js | 43 ++++++++++ ...0816130800-create-flag_types_dictionary.js | 50 +++++++++++ ...0816130900-create-quality_control_flags.js | 85 +++++++++++++++++++ .../20230816131000-create-verifications.js | 46 ++++++++++ .../20230816131100-create-anchored_periods.js | 40 +++++++++ .../20230816131200-create-data_passes_runs.js | 40 +++++++++ ...816131300-create-simulation_passes_runs.js | 40 +++++++++ .../20230816131400-create-anchored_passes.js | 40 +++++++++ ...0230816131500-create-particle_phys_data.js | 49 +++++++++++ .../migrations/20230816131600-create-meta.js | 43 ++++++++++ 16 files changed, 749 insertions(+) create mode 100644 app/lib/database/migrations/20230816130100-create-beams_dictionary.js create mode 100644 app/lib/database/migrations/20230816130200-create-periods.js create mode 100644 app/lib/database/migrations/20230816130300-create-runs.js create mode 100644 app/lib/database/migrations/20230816130400-create-detectors_subsystems.js create mode 100644 app/lib/database/migrations/20230816130500-create-data_passes.js create mode 100644 app/lib/database/migrations/20230816130600-create-simulation_passes.js create mode 100644 app/lib/database/migrations/20230816130700-create-runs_detectors.js create mode 100644 app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js create mode 100644 app/lib/database/migrations/20230816130900-create-quality_control_flags.js create mode 100644 app/lib/database/migrations/20230816131000-create-verifications.js create mode 100644 app/lib/database/migrations/20230816131100-create-anchored_periods.js create mode 100644 app/lib/database/migrations/20230816131200-create-data_passes_runs.js create mode 100644 app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js create mode 100644 app/lib/database/migrations/20230816131400-create-anchored_passes.js create mode 100644 app/lib/database/migrations/20230816131500-create-particle_phys_data.js create mode 100644 app/lib/database/migrations/20230816131600-create-meta.js diff --git a/app/lib/database/migrations/20230816130100-create-beams_dictionary.js b/app/lib/database/migrations/20230816130100-create-beams_dictionary.js new file mode 100644 index 000000000..838c9eb94 --- /dev/null +++ b/app/lib/database/migrations/20230816130100-create-beams_dictionary.js @@ -0,0 +1,34 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('beams_dictionary', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + beam_type: { + type: Sequelize.STRING, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('beams_dictionary'); + } +}; diff --git a/app/lib/database/migrations/20230816130200-create-periods.js b/app/lib/database/migrations/20230816130200-create-periods.js new file mode 100644 index 000000000..6e20336f2 --- /dev/null +++ b/app/lib/database/migrations/20230816130200-create-periods.js @@ -0,0 +1,45 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('periods', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + year: { + type: Sequelize.INTEGER, + }, + beam_type_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'beams_dictionary', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('periods'); + } +}; diff --git a/app/lib/database/migrations/20230816130300-create-runs.js b/app/lib/database/migrations/20230816130300-create-runs.js new file mode 100644 index 000000000..8bba324ab --- /dev/null +++ b/app/lib/database/migrations/20230816130300-create-runs.js @@ -0,0 +1,57 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + }, + time_start: { + type: Sequelize.BIGINT, + }, + time_end: { + type: Sequelize.BIGINT, + }, + time_trg_start: { + type: Sequelize.BIGINT, + }, + time_trg_end: { + type: Sequelize.BIGINT, + }, + energy_per_beam: { + type: Sequelize.FLOAT, + }, + l3_current: { + type: Sequelize.FLOAT, + }, + dipole_current: { + type: Sequelize.FLOAT, + }, + period_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'periods', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('runs'); + } +}; diff --git a/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js b/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js new file mode 100644 index 000000000..e0f81a190 --- /dev/null +++ b/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js @@ -0,0 +1,34 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('detectors_subsystems', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('detectors_subsystems'); + } +}; diff --git a/app/lib/database/migrations/20230816130500-create-data_passes.js b/app/lib/database/migrations/20230816130500-create-data_passes.js new file mode 100644 index 000000000..eebe6e3e7 --- /dev/null +++ b/app/lib/database/migrations/20230816130500-create-data_passes.js @@ -0,0 +1,54 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('data_passes', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + description: { + type: Sequelize.TEXT, + }, + number_of_events: { + type: Sequelize.INTEGER, + }, + size: { + type: Sequelize.REAL, + }, + last_run: { + type: Sequelize.INTEGER, + }, + period_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'periods', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('data_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816130600-create-simulation_passes.js b/app/lib/database/migrations/20230816130600-create-simulation_passes.js new file mode 100644 index 000000000..47244e649 --- /dev/null +++ b/app/lib/database/migrations/20230816130600-create-simulation_passes.js @@ -0,0 +1,49 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('simulation_passes', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + description: { + type: Sequelize.TEXT, + }, + jira: { + type: Sequelize.STRING, + }, + pwg: { + type: Sequelize.TEXT, + }, + number_of_events: { + type: Sequelize.INTEGER, + }, + size: { + type: Sequelize.REAL, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('simulation_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816130700-create-runs_detectors.js b/app/lib/database/migrations/20230816130700-create-runs_detectors.js new file mode 100644 index 000000000..2ec97b7dd --- /dev/null +++ b/app/lib/database/migrations/20230816130700-create-runs_detectors.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('runs_detectors', { + quality: { + type: Sequelize.STRING, + }, + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + detector_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'detectors_subsystems', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('runs_detectors'); + } +}; diff --git a/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js b/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js new file mode 100644 index 000000000..68e76b7b8 --- /dev/null +++ b/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js @@ -0,0 +1,50 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('flag_types_dictionary', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + method: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + bad: { + type: Sequelize.BOOLEAN, + unique: true, + allowNull: false, + }, + obsolate: { + type: Sequelize.BOOLEAN, + unique: true, + allowNull: false, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('flag_types_dictionary'); + } +}; diff --git a/app/lib/database/migrations/20230816130900-create-quality_control_flags.js b/app/lib/database/migrations/20230816130900-create-quality_control_flags.js new file mode 100644 index 000000000..f7745cc74 --- /dev/null +++ b/app/lib/database/migrations/20230816130900-create-quality_control_flags.js @@ -0,0 +1,85 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('quality_control_flags', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + time_start: { + type: Sequelize.DATE, + allowNull: false, + }, + time_end: { + type: Sequelize.DATE, + allowNull: false, + }, + comment: { + type: Sequelize.TEXT, + }, + added_by: { + type: Sequelize.STRING, + allowNull: false, + }, + addition_time: { + type: Sequelize.DATE, + allowNull: false, + }, + last_modification_time: { + type: Sequelize.DATE, + allowNull: false, + }, + run_number: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + data_pass_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + detector_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'detectors_subsystems', + key: 'id', + }, + }, + flag_type_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'flag_types_dictionary', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('quality_control_flags'); + } +}; diff --git a/app/lib/database/migrations/20230816131000-create-verifications.js b/app/lib/database/migrations/20230816131000-create-verifications.js new file mode 100644 index 000000000..3101fa158 --- /dev/null +++ b/app/lib/database/migrations/20230816131000-create-verifications.js @@ -0,0 +1,46 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('verifications', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + verified_by: { + type: Sequelize.STRING, + allowNull: false, + }, + verification_time: { + type: Sequelize.DATE, + allowNull: false, + }, + qcf_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'quality_control_flags', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('verifications'); + } +}; diff --git a/app/lib/database/migrations/20230816131100-create-anchored_periods.js b/app/lib/database/migrations/20230816131100-create-anchored_periods.js new file mode 100644 index 000000000..89b3acbf4 --- /dev/null +++ b/app/lib/database/migrations/20230816131100-create-anchored_periods.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('anchored_periods', { + period_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'periods', + key: 'id', + }, + }, + sim_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('anchored_periods'); + } +}; diff --git a/app/lib/database/migrations/20230816131200-create-data_passes_runs.js b/app/lib/database/migrations/20230816131200-create-data_passes_runs.js new file mode 100644 index 000000000..d78ed14cc --- /dev/null +++ b/app/lib/database/migrations/20230816131200-create-data_passes_runs.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('data_passes_runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + data_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('data_passes_runs'); + } +}; diff --git a/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js b/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js new file mode 100644 index 000000000..7c517be4a --- /dev/null +++ b/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('simulation_passes_runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + simulation_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('simulation_passes_runs'); + } +}; diff --git a/app/lib/database/migrations/20230816131400-create-anchored_passes.js b/app/lib/database/migrations/20230816131400-create-anchored_passes.js new file mode 100644 index 000000000..0b7ed8aaf --- /dev/null +++ b/app/lib/database/migrations/20230816131400-create-anchored_passes.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('anchored_passes', { + data_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + sim_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('anchored_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816131500-create-particle_phys_data.js b/app/lib/database/migrations/20230816131500-create-particle_phys_data.js new file mode 100644 index 000000000..edcf93024 --- /dev/null +++ b/app/lib/database/migrations/20230816131500-create-particle_phys_data.js @@ -0,0 +1,49 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('particle_phys_data', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + full_name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + a: { + type: Sequelize.SMALLINT, + allowNull: false, + }, + z: { + type: Sequelize.SMALLINT, + allowNull: false, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('particle_phys_data'); + } +}; diff --git a/app/lib/database/migrations/20230816131600-create-meta.js b/app/lib/database/migrations/20230816131600-create-meta.js new file mode 100644 index 000000000..153237d6d --- /dev/null +++ b/app/lib/database/migrations/20230816131600-create-meta.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('meta', { + name: { + primaryKey: true, + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + val: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + }, + created_at: { + type: Sequelize.DATE, + allowNull: false, + }, + updated_at: { + type: Sequelize.DATE, + allowNull: false, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('meta'); + } +}; From 25414640369e016ef63068a7ff3e22215ae739fa Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:55:31 +0200 Subject: [PATCH 07/20] removed unnecessary --- .../functions/prepere_query.sql | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 database/stored-sql-functionalities/functions/prepere_query.sql diff --git a/database/stored-sql-functionalities/functions/prepere_query.sql b/database/stored-sql-functionalities/functions/prepere_query.sql deleted file mode 100644 index 1f19bb63d..000000000 --- a/database/stored-sql-functionalities/functions/prepere_query.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE or REPLACE FUNCTION prepare_runs_one_hot_query() - returns varchar -language plpgsql -as $body$ -declare ret varchar:= null; -declare v varchar:= null; -BEGIN - v = '(SELECT r.run_number, ds.name - FROM runs as r - INNER JOIN runs_detectors as rd - ON rd.run_number = r.run_number - INNER JOIN detectors_subsystems as ds - ON ds.id = rd.detector_id)'; - SELECT 'SELECT run_number, ' || - string_agg(format(E'\n MAX(case when name=\'%s\' then %s else 0 end) %s_detector', name, id, name), ',') || - E'\n FROM ' || v || E' AS runs_detectors_join\n' || E' GROUP BY run_number' into ret - FROM (SELECT distinct id, name FROM detectors_subsystems) as sub; - return ret; -END; -$body$; From 120227f6818b826db1a0048b0f68edebcba3c2ac Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:55:55 +0200 Subject: [PATCH 08/20] rename --- .../functions/get_center_of_mass_energy.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/stored-sql-functionalities/functions/get_center_of_mass_energy.sql b/database/stored-sql-functionalities/functions/get_center_of_mass_energy.sql index cfab4a380..aca9b6307 100644 --- a/database/stored-sql-functionalities/functions/get_center_of_mass_energy.sql +++ b/database/stored-sql-functionalities/functions/get_center_of_mass_energy.sql @@ -27,7 +27,7 @@ BEGIN end if; foreach beam_t in array beam_type_split loop - SELECT "A", "Z" INTO Av, Zv FROM particle_phys_data WHERE name = beam_t; + SELECT a, z INTO Av, Zv FROM particle_phys_data WHERE name = beam_t; IF Av is null or Zv is null then raise exception 'no defintion for particle of name: "%"', beam_t; end if; From f3ae8a5b8e50fb7172c8729cf9d8c8d3d0a5e32f Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:56:14 +0200 Subject: [PATCH 09/20] rename --- app/config/rct-data/healthcheckQueries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/rct-data/healthcheckQueries.js b/app/config/rct-data/healthcheckQueries.js index 8d30ed39e..8fc784572 100644 --- a/app/config/rct-data/healthcheckQueries.js +++ b/app/config/rct-data/healthcheckQueries.js @@ -23,7 +23,7 @@ const checkStaticData = { }, particle: { description: 'Particles dict insert', - query: Object.entries(physicalParticlesData).map(([name, d]) => `INSERT INTO particle_phys_data("id", "name", "full_name", "A", "Z") + query: Object.entries(physicalParticlesData).map(([name, d]) => `INSERT INTO particle_phys_data("id", "name", "full_name", "a", "z") VALUES (DEFAULT, '${name}', '${d.full_name}', ${d.A}, ${d.Z});`), }, flags: { From 88fff1da11379fefdffea593022b588abe4fcfc8 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:04:59 +0200 Subject: [PATCH 10/20] add fillNumber to Run model --- .../20230816130100-create-beams_dictionary.js | 34 -------- .../20230816130200-create-periods.js | 45 ---------- .../migrations/20230816130300-create-runs.js | 57 ------------- ...30816130400-create-detectors_subsystems.js | 34 -------- .../20230816130500-create-data_passes.js | 54 ------------ ...20230816130600-create-simulation_passes.js | 49 ----------- .../20230816130700-create-runs_detectors.js | 43 ---------- ...0816130800-create-flag_types_dictionary.js | 50 ----------- ...0816130900-create-quality_control_flags.js | 85 ------------------- .../20230816131000-create-verifications.js | 46 ---------- .../20230816131100-create-anchored_periods.js | 40 --------- .../20230816131200-create-data_passes_runs.js | 40 --------- ...816131300-create-simulation_passes_runs.js | 40 --------- .../20230816131400-create-anchored_passes.js | 40 --------- ...0230816131500-create-particle_phys_data.js | 49 ----------- .../migrations/20230816131600-create-meta.js | 43 ---------- app/lib/database/models/Run.js | 3 + 17 files changed, 3 insertions(+), 749 deletions(-) delete mode 100644 app/lib/database/migrations/20230816130100-create-beams_dictionary.js delete mode 100644 app/lib/database/migrations/20230816130200-create-periods.js delete mode 100644 app/lib/database/migrations/20230816130300-create-runs.js delete mode 100644 app/lib/database/migrations/20230816130400-create-detectors_subsystems.js delete mode 100644 app/lib/database/migrations/20230816130500-create-data_passes.js delete mode 100644 app/lib/database/migrations/20230816130600-create-simulation_passes.js delete mode 100644 app/lib/database/migrations/20230816130700-create-runs_detectors.js delete mode 100644 app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js delete mode 100644 app/lib/database/migrations/20230816130900-create-quality_control_flags.js delete mode 100644 app/lib/database/migrations/20230816131000-create-verifications.js delete mode 100644 app/lib/database/migrations/20230816131100-create-anchored_periods.js delete mode 100644 app/lib/database/migrations/20230816131200-create-data_passes_runs.js delete mode 100644 app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js delete mode 100644 app/lib/database/migrations/20230816131400-create-anchored_passes.js delete mode 100644 app/lib/database/migrations/20230816131500-create-particle_phys_data.js delete mode 100644 app/lib/database/migrations/20230816131600-create-meta.js diff --git a/app/lib/database/migrations/20230816130100-create-beams_dictionary.js b/app/lib/database/migrations/20230816130100-create-beams_dictionary.js deleted file mode 100644 index 838c9eb94..000000000 --- a/app/lib/database/migrations/20230816130100-create-beams_dictionary.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('beams_dictionary', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - beam_type: { - type: Sequelize.STRING, - unique: true, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('beams_dictionary'); - } -}; diff --git a/app/lib/database/migrations/20230816130200-create-periods.js b/app/lib/database/migrations/20230816130200-create-periods.js deleted file mode 100644 index 6e20336f2..000000000 --- a/app/lib/database/migrations/20230816130200-create-periods.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('periods', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - }, - year: { - type: Sequelize.INTEGER, - }, - beam_type_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'beams_dictionary', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('periods'); - } -}; diff --git a/app/lib/database/migrations/20230816130300-create-runs.js b/app/lib/database/migrations/20230816130300-create-runs.js deleted file mode 100644 index 8bba324ab..000000000 --- a/app/lib/database/migrations/20230816130300-create-runs.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('runs', { - run_number: { - type: Sequelize.INTEGER, - primaryKey: true, - }, - time_start: { - type: Sequelize.BIGINT, - }, - time_end: { - type: Sequelize.BIGINT, - }, - time_trg_start: { - type: Sequelize.BIGINT, - }, - time_trg_end: { - type: Sequelize.BIGINT, - }, - energy_per_beam: { - type: Sequelize.FLOAT, - }, - l3_current: { - type: Sequelize.FLOAT, - }, - dipole_current: { - type: Sequelize.FLOAT, - }, - period_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'periods', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('runs'); - } -}; diff --git a/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js b/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js deleted file mode 100644 index e0f81a190..000000000 --- a/app/lib/database/migrations/20230816130400-create-detectors_subsystems.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('detectors_subsystems', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('detectors_subsystems'); - } -}; diff --git a/app/lib/database/migrations/20230816130500-create-data_passes.js b/app/lib/database/migrations/20230816130500-create-data_passes.js deleted file mode 100644 index eebe6e3e7..000000000 --- a/app/lib/database/migrations/20230816130500-create-data_passes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('data_passes', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - }, - description: { - type: Sequelize.TEXT, - }, - number_of_events: { - type: Sequelize.INTEGER, - }, - size: { - type: Sequelize.REAL, - }, - last_run: { - type: Sequelize.INTEGER, - }, - period_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'periods', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('data_passes'); - } -}; diff --git a/app/lib/database/migrations/20230816130600-create-simulation_passes.js b/app/lib/database/migrations/20230816130600-create-simulation_passes.js deleted file mode 100644 index 47244e649..000000000 --- a/app/lib/database/migrations/20230816130600-create-simulation_passes.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('simulation_passes', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - }, - description: { - type: Sequelize.TEXT, - }, - jira: { - type: Sequelize.STRING, - }, - pwg: { - type: Sequelize.TEXT, - }, - number_of_events: { - type: Sequelize.INTEGER, - }, - size: { - type: Sequelize.REAL, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('simulation_passes'); - } -}; diff --git a/app/lib/database/migrations/20230816130700-create-runs_detectors.js b/app/lib/database/migrations/20230816130700-create-runs_detectors.js deleted file mode 100644 index 2ec97b7dd..000000000 --- a/app/lib/database/migrations/20230816130700-create-runs_detectors.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('runs_detectors', { - quality: { - type: Sequelize.STRING, - }, - run_number: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'runs', - key: 'run_number', - }, - }, - detector_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'detectors_subsystems', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('runs_detectors'); - } -}; diff --git a/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js b/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js deleted file mode 100644 index 68e76b7b8..000000000 --- a/app/lib/database/migrations/20230816130800-create-flag_types_dictionary.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('flag_types_dictionary', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - allowNull: false, - }, - method: { - type: Sequelize.STRING, - unique: true, - allowNull: false, - }, - bad: { - type: Sequelize.BOOLEAN, - unique: true, - allowNull: false, - }, - obsolate: { - type: Sequelize.BOOLEAN, - unique: true, - allowNull: false, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('flag_types_dictionary'); - } -}; diff --git a/app/lib/database/migrations/20230816130900-create-quality_control_flags.js b/app/lib/database/migrations/20230816130900-create-quality_control_flags.js deleted file mode 100644 index f7745cc74..000000000 --- a/app/lib/database/migrations/20230816130900-create-quality_control_flags.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('quality_control_flags', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - time_start: { - type: Sequelize.DATE, - allowNull: false, - }, - time_end: { - type: Sequelize.DATE, - allowNull: false, - }, - comment: { - type: Sequelize.TEXT, - }, - added_by: { - type: Sequelize.STRING, - allowNull: false, - }, - addition_time: { - type: Sequelize.DATE, - allowNull: false, - }, - last_modification_time: { - type: Sequelize.DATE, - allowNull: false, - }, - run_number: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'runs', - key: 'run_number', - }, - }, - data_pass_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'data_passes', - key: 'id', - }, - }, - detector_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'detectors_subsystems', - key: 'id', - }, - }, - flag_type_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'flag_types_dictionary', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('quality_control_flags'); - } -}; diff --git a/app/lib/database/migrations/20230816131000-create-verifications.js b/app/lib/database/migrations/20230816131000-create-verifications.js deleted file mode 100644 index 3101fa158..000000000 --- a/app/lib/database/migrations/20230816131000-create-verifications.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('verifications', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - verified_by: { - type: Sequelize.STRING, - allowNull: false, - }, - verification_time: { - type: Sequelize.DATE, - allowNull: false, - }, - qcf_id: { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'quality_control_flags', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('verifications'); - } -}; diff --git a/app/lib/database/migrations/20230816131100-create-anchored_periods.js b/app/lib/database/migrations/20230816131100-create-anchored_periods.js deleted file mode 100644 index 89b3acbf4..000000000 --- a/app/lib/database/migrations/20230816131100-create-anchored_periods.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('anchored_periods', { - period_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'periods', - key: 'id', - }, - }, - sim_pass_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'simulation_passes', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('anchored_periods'); - } -}; diff --git a/app/lib/database/migrations/20230816131200-create-data_passes_runs.js b/app/lib/database/migrations/20230816131200-create-data_passes_runs.js deleted file mode 100644 index d78ed14cc..000000000 --- a/app/lib/database/migrations/20230816131200-create-data_passes_runs.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('data_passes_runs', { - run_number: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'runs', - key: 'run_number', - }, - }, - data_pass_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'data_passes', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('data_passes_runs'); - } -}; diff --git a/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js b/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js deleted file mode 100644 index 7c517be4a..000000000 --- a/app/lib/database/migrations/20230816131300-create-simulation_passes_runs.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('simulation_passes_runs', { - run_number: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'runs', - key: 'run_number', - }, - }, - simulation_pass_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'simulation_passes', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('simulation_passes_runs'); - } -}; diff --git a/app/lib/database/migrations/20230816131400-create-anchored_passes.js b/app/lib/database/migrations/20230816131400-create-anchored_passes.js deleted file mode 100644 index 0b7ed8aaf..000000000 --- a/app/lib/database/migrations/20230816131400-create-anchored_passes.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('anchored_passes', { - data_pass_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'data_passes', - key: 'id', - }, - }, - sim_pass_id: { - type: Sequelize.INTEGER, - primaryKey: true, - references: { - model: 'simulation_passes', - key: 'id', - }, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('anchored_passes'); - } -}; diff --git a/app/lib/database/migrations/20230816131500-create-particle_phys_data.js b/app/lib/database/migrations/20230816131500-create-particle_phys_data.js deleted file mode 100644 index edcf93024..000000000 --- a/app/lib/database/migrations/20230816131500-create-particle_phys_data.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('particle_phys_data', { - id: { - type: Sequelize.INTEGER, - allowNull: false, - primaryKey: true, - autoIncrement: true, - }, - name: { - type: Sequelize.STRING, - unique: true, - allowNull: false, - }, - full_name: { - type: Sequelize.STRING, - unique: true, - allowNull: false, - }, - a: { - type: Sequelize.SMALLINT, - allowNull: false, - }, - z: { - type: Sequelize.SMALLINT, - allowNull: false, - unique: true, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('particle_phys_data'); - } -}; diff --git a/app/lib/database/migrations/20230816131600-create-meta.js b/app/lib/database/migrations/20230816131600-create-meta.js deleted file mode 100644 index 153237d6d..000000000 --- a/app/lib/database/migrations/20230816131600-create-meta.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -/** @type {import('sequelize-cli').Migration} */ -module.exports = { - async up(queryInterface, Sequelize) { - await queryInterface.createTable('meta', { - name: { - primaryKey: true, - type: Sequelize.STRING, - unique: true, - allowNull: false, - }, - val: { - type: Sequelize.STRING, - allowNull: false, - unique: true, - }, - created_at: { - type: Sequelize.DATE, - allowNull: false, - }, - updated_at: { - type: Sequelize.DATE, - allowNull: false, - }, - }, - ) - }, - async down(queryInterface, Sequelize) { - await queryInterface.dropTable('meta'); - } -}; diff --git a/app/lib/database/models/Run.js b/app/lib/database/models/Run.js index b317e5a09..aa93860c1 100644 --- a/app/lib/database/models/Run.js +++ b/app/lib/database/models/Run.js @@ -91,6 +91,9 @@ module.exports = (sequelize) => { type: Sequelize.FLOAT, field: 'dipole_current', }, + fillNumber: { + type: Sequelize.INTEGER, + } }, { timestamps: false }); From 146548adedcf91dcc0fa9476185bc3f5be041488 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:05:08 +0200 Subject: [PATCH 11/20] add fillNumber to Run model --- .../20230816140100-create-beams_dictionary.js | 34 ++++++++ .../20230816140200-create-periods.js | 45 ++++++++++ .../migrations/20230816140300-create-runs.js | 60 +++++++++++++ ...30816140400-create-detectors_subsystems.js | 34 ++++++++ .../20230816140500-create-data_passes.js | 54 ++++++++++++ ...20230816140600-create-simulation_passes.js | 49 +++++++++++ .../20230816140700-create-runs_detectors.js | 43 ++++++++++ ...0816140800-create-flag_types_dictionary.js | 50 +++++++++++ ...0816140900-create-quality_control_flags.js | 85 +++++++++++++++++++ .../20230816141000-create-verifications.js | 46 ++++++++++ .../20230816141100-create-anchored_periods.js | 40 +++++++++ .../20230816141200-create-data_passes_runs.js | 40 +++++++++ ...816141300-create-simulation_passes_runs.js | 40 +++++++++ .../20230816141400-create-anchored_passes.js | 40 +++++++++ ...0230816141500-create-particle_phys_data.js | 49 +++++++++++ .../migrations/20230816141600-create-meta.js | 43 ++++++++++ 16 files changed, 752 insertions(+) create mode 100644 app/lib/database/migrations/20230816140100-create-beams_dictionary.js create mode 100644 app/lib/database/migrations/20230816140200-create-periods.js create mode 100644 app/lib/database/migrations/20230816140300-create-runs.js create mode 100644 app/lib/database/migrations/20230816140400-create-detectors_subsystems.js create mode 100644 app/lib/database/migrations/20230816140500-create-data_passes.js create mode 100644 app/lib/database/migrations/20230816140600-create-simulation_passes.js create mode 100644 app/lib/database/migrations/20230816140700-create-runs_detectors.js create mode 100644 app/lib/database/migrations/20230816140800-create-flag_types_dictionary.js create mode 100644 app/lib/database/migrations/20230816140900-create-quality_control_flags.js create mode 100644 app/lib/database/migrations/20230816141000-create-verifications.js create mode 100644 app/lib/database/migrations/20230816141100-create-anchored_periods.js create mode 100644 app/lib/database/migrations/20230816141200-create-data_passes_runs.js create mode 100644 app/lib/database/migrations/20230816141300-create-simulation_passes_runs.js create mode 100644 app/lib/database/migrations/20230816141400-create-anchored_passes.js create mode 100644 app/lib/database/migrations/20230816141500-create-particle_phys_data.js create mode 100644 app/lib/database/migrations/20230816141600-create-meta.js diff --git a/app/lib/database/migrations/20230816140100-create-beams_dictionary.js b/app/lib/database/migrations/20230816140100-create-beams_dictionary.js new file mode 100644 index 000000000..838c9eb94 --- /dev/null +++ b/app/lib/database/migrations/20230816140100-create-beams_dictionary.js @@ -0,0 +1,34 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('beams_dictionary', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + beam_type: { + type: Sequelize.STRING, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('beams_dictionary'); + } +}; diff --git a/app/lib/database/migrations/20230816140200-create-periods.js b/app/lib/database/migrations/20230816140200-create-periods.js new file mode 100644 index 000000000..6e20336f2 --- /dev/null +++ b/app/lib/database/migrations/20230816140200-create-periods.js @@ -0,0 +1,45 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('periods', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + year: { + type: Sequelize.INTEGER, + }, + beam_type_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'beams_dictionary', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('periods'); + } +}; diff --git a/app/lib/database/migrations/20230816140300-create-runs.js b/app/lib/database/migrations/20230816140300-create-runs.js new file mode 100644 index 000000000..f66f9e210 --- /dev/null +++ b/app/lib/database/migrations/20230816140300-create-runs.js @@ -0,0 +1,60 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + }, + time_start: { + type: Sequelize.BIGINT, + }, + time_end: { + type: Sequelize.BIGINT, + }, + time_trg_start: { + type: Sequelize.BIGINT, + }, + time_trg_end: { + type: Sequelize.BIGINT, + }, + energy_per_beam: { + type: Sequelize.FLOAT, + }, + l3_current: { + type: Sequelize.FLOAT, + }, + dipole_current: { + type: Sequelize.FLOAT, + }, + fill_number: { + type: Sequelize.INTEGER, + }, + period_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'periods', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('runs'); + } +}; diff --git a/app/lib/database/migrations/20230816140400-create-detectors_subsystems.js b/app/lib/database/migrations/20230816140400-create-detectors_subsystems.js new file mode 100644 index 000000000..e0f81a190 --- /dev/null +++ b/app/lib/database/migrations/20230816140400-create-detectors_subsystems.js @@ -0,0 +1,34 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('detectors_subsystems', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('detectors_subsystems'); + } +}; diff --git a/app/lib/database/migrations/20230816140500-create-data_passes.js b/app/lib/database/migrations/20230816140500-create-data_passes.js new file mode 100644 index 000000000..eebe6e3e7 --- /dev/null +++ b/app/lib/database/migrations/20230816140500-create-data_passes.js @@ -0,0 +1,54 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('data_passes', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + description: { + type: Sequelize.TEXT, + }, + number_of_events: { + type: Sequelize.INTEGER, + }, + size: { + type: Sequelize.REAL, + }, + last_run: { + type: Sequelize.INTEGER, + }, + period_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'periods', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('data_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816140600-create-simulation_passes.js b/app/lib/database/migrations/20230816140600-create-simulation_passes.js new file mode 100644 index 000000000..47244e649 --- /dev/null +++ b/app/lib/database/migrations/20230816140600-create-simulation_passes.js @@ -0,0 +1,49 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('simulation_passes', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + }, + description: { + type: Sequelize.TEXT, + }, + jira: { + type: Sequelize.STRING, + }, + pwg: { + type: Sequelize.TEXT, + }, + number_of_events: { + type: Sequelize.INTEGER, + }, + size: { + type: Sequelize.REAL, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('simulation_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816140700-create-runs_detectors.js b/app/lib/database/migrations/20230816140700-create-runs_detectors.js new file mode 100644 index 000000000..2ec97b7dd --- /dev/null +++ b/app/lib/database/migrations/20230816140700-create-runs_detectors.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('runs_detectors', { + quality: { + type: Sequelize.STRING, + }, + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + detector_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'detectors_subsystems', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('runs_detectors'); + } +}; diff --git a/app/lib/database/migrations/20230816140800-create-flag_types_dictionary.js b/app/lib/database/migrations/20230816140800-create-flag_types_dictionary.js new file mode 100644 index 000000000..68e76b7b8 --- /dev/null +++ b/app/lib/database/migrations/20230816140800-create-flag_types_dictionary.js @@ -0,0 +1,50 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('flag_types_dictionary', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + method: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + bad: { + type: Sequelize.BOOLEAN, + unique: true, + allowNull: false, + }, + obsolate: { + type: Sequelize.BOOLEAN, + unique: true, + allowNull: false, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('flag_types_dictionary'); + } +}; diff --git a/app/lib/database/migrations/20230816140900-create-quality_control_flags.js b/app/lib/database/migrations/20230816140900-create-quality_control_flags.js new file mode 100644 index 000000000..f7745cc74 --- /dev/null +++ b/app/lib/database/migrations/20230816140900-create-quality_control_flags.js @@ -0,0 +1,85 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('quality_control_flags', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + time_start: { + type: Sequelize.DATE, + allowNull: false, + }, + time_end: { + type: Sequelize.DATE, + allowNull: false, + }, + comment: { + type: Sequelize.TEXT, + }, + added_by: { + type: Sequelize.STRING, + allowNull: false, + }, + addition_time: { + type: Sequelize.DATE, + allowNull: false, + }, + last_modification_time: { + type: Sequelize.DATE, + allowNull: false, + }, + run_number: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + data_pass_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + detector_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'detectors_subsystems', + key: 'id', + }, + }, + flag_type_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'flag_types_dictionary', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('quality_control_flags'); + } +}; diff --git a/app/lib/database/migrations/20230816141000-create-verifications.js b/app/lib/database/migrations/20230816141000-create-verifications.js new file mode 100644 index 000000000..3101fa158 --- /dev/null +++ b/app/lib/database/migrations/20230816141000-create-verifications.js @@ -0,0 +1,46 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('verifications', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + verified_by: { + type: Sequelize.STRING, + allowNull: false, + }, + verification_time: { + type: Sequelize.DATE, + allowNull: false, + }, + qcf_id: { + type: Sequelize.INTEGER, + allowNull: true, + references: { + model: 'quality_control_flags', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('verifications'); + } +}; diff --git a/app/lib/database/migrations/20230816141100-create-anchored_periods.js b/app/lib/database/migrations/20230816141100-create-anchored_periods.js new file mode 100644 index 000000000..89b3acbf4 --- /dev/null +++ b/app/lib/database/migrations/20230816141100-create-anchored_periods.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('anchored_periods', { + period_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'periods', + key: 'id', + }, + }, + sim_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('anchored_periods'); + } +}; diff --git a/app/lib/database/migrations/20230816141200-create-data_passes_runs.js b/app/lib/database/migrations/20230816141200-create-data_passes_runs.js new file mode 100644 index 000000000..d78ed14cc --- /dev/null +++ b/app/lib/database/migrations/20230816141200-create-data_passes_runs.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('data_passes_runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + data_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('data_passes_runs'); + } +}; diff --git a/app/lib/database/migrations/20230816141300-create-simulation_passes_runs.js b/app/lib/database/migrations/20230816141300-create-simulation_passes_runs.js new file mode 100644 index 000000000..7c517be4a --- /dev/null +++ b/app/lib/database/migrations/20230816141300-create-simulation_passes_runs.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('simulation_passes_runs', { + run_number: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'runs', + key: 'run_number', + }, + }, + simulation_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('simulation_passes_runs'); + } +}; diff --git a/app/lib/database/migrations/20230816141400-create-anchored_passes.js b/app/lib/database/migrations/20230816141400-create-anchored_passes.js new file mode 100644 index 000000000..0b7ed8aaf --- /dev/null +++ b/app/lib/database/migrations/20230816141400-create-anchored_passes.js @@ -0,0 +1,40 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('anchored_passes', { + data_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'data_passes', + key: 'id', + }, + }, + sim_pass_id: { + type: Sequelize.INTEGER, + primaryKey: true, + references: { + model: 'simulation_passes', + key: 'id', + }, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('anchored_passes'); + } +}; diff --git a/app/lib/database/migrations/20230816141500-create-particle_phys_data.js b/app/lib/database/migrations/20230816141500-create-particle_phys_data.js new file mode 100644 index 000000000..edcf93024 --- /dev/null +++ b/app/lib/database/migrations/20230816141500-create-particle_phys_data.js @@ -0,0 +1,49 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('particle_phys_data', { + id: { + type: Sequelize.INTEGER, + allowNull: false, + primaryKey: true, + autoIncrement: true, + }, + name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + full_name: { + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + a: { + type: Sequelize.SMALLINT, + allowNull: false, + }, + z: { + type: Sequelize.SMALLINT, + allowNull: false, + unique: true, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('particle_phys_data'); + } +}; diff --git a/app/lib/database/migrations/20230816141600-create-meta.js b/app/lib/database/migrations/20230816141600-create-meta.js new file mode 100644 index 000000000..153237d6d --- /dev/null +++ b/app/lib/database/migrations/20230816141600-create-meta.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.createTable('meta', { + name: { + primaryKey: true, + type: Sequelize.STRING, + unique: true, + allowNull: false, + }, + val: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + }, + created_at: { + type: Sequelize.DATE, + allowNull: false, + }, + updated_at: { + type: Sequelize.DATE, + allowNull: false, + }, + }, + ) + }, + async down(queryInterface, Sequelize) { + await queryInterface.dropTable('meta'); + } +}; From 6b49e0f233bd6e81bd09f9dc13cb22d649003c19 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:07:07 +0200 Subject: [PATCH 12/20] add runType --- app/lib/database/migrations/20230816140300-create-runs.js | 4 ++++ app/lib/database/models/Run.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/lib/database/migrations/20230816140300-create-runs.js b/app/lib/database/migrations/20230816140300-create-runs.js index f66f9e210..d3a54a632 100644 --- a/app/lib/database/migrations/20230816140300-create-runs.js +++ b/app/lib/database/migrations/20230816140300-create-runs.js @@ -43,6 +43,10 @@ module.exports = { fill_number: { type: Sequelize.INTEGER, }, + run_type: { + type: Sequelize.STRING, + allowNull: false, + }, period_id: { type: Sequelize.INTEGER, allowNull: true, diff --git a/app/lib/database/models/Run.js b/app/lib/database/models/Run.js index aa93860c1..4c4eb527e 100644 --- a/app/lib/database/models/Run.js +++ b/app/lib/database/models/Run.js @@ -93,6 +93,10 @@ module.exports = (sequelize) => { }, fillNumber: { type: Sequelize.INTEGER, + }, + runType: { + type: Sequelize.STRING, + allowNull: false } }, { timestamps: false }); From 1d3104c674b7431783d3ec4a9e16654b44434452 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:27:45 +0200 Subject: [PATCH 13/20] run modele and sync procedure cleanup --- app/lib/database/models/Run.js | 2 +- app/lib/database/views/runs_views.js | 4 ---- database/stored-sql-functionalities/procedures/insert_run.sql | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/lib/database/models/Run.js b/app/lib/database/models/Run.js index 4c4eb527e..41051a0aa 100644 --- a/app/lib/database/models/Run.js +++ b/app/lib/database/models/Run.js @@ -97,7 +97,7 @@ module.exports = (sequelize) => { runType: { type: Sequelize.STRING, allowNull: false - } + }, }, { timestamps: false }); diff --git a/app/lib/database/views/runs_views.js b/app/lib/database/views/runs_views.js index c2b425b08..152e50c9f 100644 --- a/app/lib/database/views/runs_views.js +++ b/app/lib/database/views/runs_views.js @@ -25,11 +25,7 @@ const queryForRunsFields = ` r.time_trg_start, r.time_trg_end, get_center_of_mass_energy(r.energy_per_beam, p.beam_type_id) as center_of_mass_energy, - r.ir, - r.filling_scheme, - r.triggers_conf, r.fill_number, - r.mu, r.l3_current, r.dipole_current `; diff --git a/database/stored-sql-functionalities/procedures/insert_run.sql b/database/stored-sql-functionalities/procedures/insert_run.sql index be523ede8..f00abe366 100644 --- a/database/stored-sql-functionalities/procedures/insert_run.sql +++ b/database/stored-sql-functionalities/procedures/insert_run.sql @@ -31,8 +31,8 @@ BEGIN raise notice 'id: %', trg_id; IF NOT EXISTS (SELECT * FROM runs WHERE run_number = _run_number) THEN - INSERT INTO runs(period_id, run_number, time_start, time_end, energy_per_beam, ir, filling_scheme, triggers_conf, fill_number, run_type, mu, time_trg_start, time_trg_end, l3_current, dipole_current) - VALUES(trg_id, _run_number, _time_start, _time_end, _energy_per_beam, null, null, null, _fill_number, _run_type, null, _time_trg_start, _time_trg_end, _l3_current, _dipole_current); + INSERT INTO runs(period_id, run_number, time_start, time_end, energy_per_beam, fill_number, run_type, time_trg_start, time_trg_end, l3_current, dipole_current) + VALUES(trg_id, _run_number, _time_start, _time_end, _energy_per_beam, _fill_number, _run_type, _time_trg_start, _time_trg_end, _l3_current, _dipole_current); ELSE raise notice 'run % already present', _run_number; From 664d50bd242aa087471a8f2895f8222a9cc2e186 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:43:39 +0200 Subject: [PATCH 14/20] amend data passes sync procedure --- app/lib/alimonitor-services/MonalisaService.js | 3 --- .../procedures/insert_prod.sql | 16 +++------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/lib/alimonitor-services/MonalisaService.js b/app/lib/alimonitor-services/MonalisaService.js index 70cc8a28d..c3c4175bd 100644 --- a/app/lib/alimonitor-services/MonalisaService.js +++ b/app/lib/alimonitor-services/MonalisaService.js @@ -79,10 +79,7 @@ class MonalisaService extends AbstractServiceSynchronizer { ${d.name}, ${d.period.name}, ${d.description}, - ${null}, - ${null}, ${d.number_of_events}, - ${null}, ${d.size}, ${d.last_run} );`; diff --git a/database/stored-sql-functionalities/procedures/insert_prod.sql b/database/stored-sql-functionalities/procedures/insert_prod.sql index 1f720a60a..31dbe8c33 100644 --- a/database/stored-sql-functionalities/procedures/insert_prod.sql +++ b/database/stored-sql-functionalities/procedures/insert_prod.sql @@ -3,10 +3,7 @@ create or replace procedure insert_prod( _name varchar, _period varchar, _description text, - _jira text, - _ml text, - _number_of_events integer, - _softwar_version text, + _number_of_events integer, _size real, _last_run integer) LANGUAGE plpgsql @@ -22,28 +19,21 @@ BEGIN SELECT id INTO trg_period_id FROM periods WHERE name = _period; END IF; - SELECT id INTO dp_id from data_passes where name = _name; IF dp_id IS NULL THEN insert into data_passes( id, - period_id , + period_id, name, description, - jira, - ml, number_of_events, - software_version, size, last_run) values ( DEFAULT, trg_period_id, _name, - _description, - _jira, - _ml, + _description, _number_of_events, - _softwar_version, _size, _last_run); ELSE From a3f15b9e7f7a661caae532fa7c603bbf868fe647 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:57:52 +0200 Subject: [PATCH 15/20] amend simulation passes sync prcedure --- app/lib/alimonitor-services/MonalisaServiceMC.js | 1 - app/lib/database/migrations/20230816140300-create-runs.js | 1 - app/lib/database/models/Run.js | 1 - database/stored-sql-functionalities/procedures/insert_mc.sql | 3 --- .../procedures/insert_mc_details.sql | 2 +- 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/lib/alimonitor-services/MonalisaServiceMC.js b/app/lib/alimonitor-services/MonalisaServiceMC.js index 3e0efdc84..54169c78d 100644 --- a/app/lib/alimonitor-services/MonalisaServiceMC.js +++ b/app/lib/alimonitor-services/MonalisaServiceMC.js @@ -108,7 +108,6 @@ class MonalisaServiceMC extends AbstractServiceSynchronizer { ${anchord_prod_sql}, ${anchord_passes_sql}, ${d.jira}, - ${null}, ${d.number_of_events}, ${d.size} ); call insert_mc_details(${d.name}, ${d.runs}::integer[], ${period.name});`; diff --git a/app/lib/database/migrations/20230816140300-create-runs.js b/app/lib/database/migrations/20230816140300-create-runs.js index d3a54a632..35e470c2c 100644 --- a/app/lib/database/migrations/20230816140300-create-runs.js +++ b/app/lib/database/migrations/20230816140300-create-runs.js @@ -45,7 +45,6 @@ module.exports = { }, run_type: { type: Sequelize.STRING, - allowNull: false, }, period_id: { type: Sequelize.INTEGER, diff --git a/app/lib/database/models/Run.js b/app/lib/database/models/Run.js index 41051a0aa..8749fd8b6 100644 --- a/app/lib/database/models/Run.js +++ b/app/lib/database/models/Run.js @@ -96,7 +96,6 @@ module.exports = (sequelize) => { }, runType: { type: Sequelize.STRING, - allowNull: false }, }, { timestamps: false }); diff --git a/database/stored-sql-functionalities/procedures/insert_mc.sql b/database/stored-sql-functionalities/procedures/insert_mc.sql index 8d7295ef1..910215036 100644 --- a/database/stored-sql-functionalities/procedures/insert_mc.sql +++ b/database/stored-sql-functionalities/procedures/insert_mc.sql @@ -6,7 +6,6 @@ create or replace procedure INSERT_mc( _anchored_periods varchar[], _anchor_passes varchar[], _jira text, - _ml text, _number_of_events integer, _size real) LANGUAGE plpgsql @@ -29,7 +28,6 @@ BEGIN name, description, jira, - ml, pwg, number_of_events, size) values ( @@ -37,7 +35,6 @@ BEGIN _name, _description, _jira, - _ml, _pwg, _number_of_events, _size); diff --git a/database/stored-sql-functionalities/procedures/insert_mc_details.sql b/database/stored-sql-functionalities/procedures/insert_mc_details.sql index 6b499154a..a40e344db 100644 --- a/database/stored-sql-functionalities/procedures/insert_mc_details.sql +++ b/database/stored-sql-functionalities/procedures/insert_mc_details.sql @@ -38,7 +38,7 @@ BEGIN RAISE EXCEPTION 'nulls %', now(); END IF; IF NOT EXISTS (SELECT * from simulation_passes_runs where run_number = _run_number and simulation_pass_id = prod_id ) then - INSERT INTO simulation_passes_runs(run_number, simulation_pass_id, qc) VALUES(_run_number, prod_id, null); + INSERT INTO simulation_passes_runs(run_number, simulation_pass_id) VALUES(_run_number, prod_id); end if; END LOOP; END; From 4f6a43578cc2a68a02f23a2dcb26245f1cb788e5 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:06:06 +0200 Subject: [PATCH 16/20] remove pgmodeler export, remove createdAt from Meta table --- app/config/rct-data/healthcheckQueries.js | 6 ++--- .../migrations/20230816141600-create-meta.js | 4 ---- app/lib/database/models/Meta.js | 2 +- database/setup-db.sh | 20 ---------------- package.json | 4 ++-- rctmake | 24 ++++++++----------- 6 files changed, 16 insertions(+), 44 deletions(-) diff --git a/app/config/rct-data/healthcheckQueries.js b/app/config/rct-data/healthcheckQueries.js index 8fc784572..c5db39cad 100644 --- a/app/config/rct-data/healthcheckQueries.js +++ b/app/config/rct-data/healthcheckQueries.js @@ -39,9 +39,9 @@ const metaObj = { }, }; -const queryForName = (name) => `SELECT name, val, extract(epoch from "updatedAt") as "udatedAt" FROM meta WHERE name = '${name}'`; -const updateForName = (name, val) => `INSERT INTO meta (name, val, "updatedAt") values ('${name}', '${val}', now()) - ON conflict (name) do update set val = EXCLUDED.val, "updatedAt" = now();`; +const queryForName = (name) => `SELECT name, val, extract(epoch from "updated_at") as "udatedAt" FROM meta WHERE name = '${name}'`; +const updateForName = (name, val) => `INSERT INTO meta (name, val, "updated_at") values ('${name}', '${val}', now()) + ON conflict (name) do update set val = EXCLUDED.val, "updated_at" = now();`; const meta = { objects: metaObj, diff --git a/app/lib/database/migrations/20230816141600-create-meta.js b/app/lib/database/migrations/20230816141600-create-meta.js index 153237d6d..af5e2609a 100644 --- a/app/lib/database/migrations/20230816141600-create-meta.js +++ b/app/lib/database/migrations/20230816141600-create-meta.js @@ -26,10 +26,6 @@ module.exports = { allowNull: false, unique: true, }, - created_at: { - type: Sequelize.DATE, - allowNull: false, - }, updated_at: { type: Sequelize.DATE, allowNull: false, diff --git a/app/lib/database/models/Meta.js b/app/lib/database/models/Meta.js index 82cf94d4f..5d80fb2f3 100644 --- a/app/lib/database/models/Meta.js +++ b/app/lib/database/models/Meta.js @@ -27,7 +27,7 @@ module.exports = (sequelize) => { unique: true, }, - }, { timestamps: true, tableName: 'meta' }); + }, { timestamps: true, createdAt: false, tableName: 'meta' }); MetaData.associate = () => {}; diff --git a/database/setup-db.sh b/database/setup-db.sh index de934daeb..b6f3bc926 100755 --- a/database/setup-db.sh +++ b/database/setup-db.sh @@ -5,7 +5,6 @@ ORG_ARGS="$*" SCRIPTS_DIR=$(dirname $0) MAIN_SCRIPT_NAME=$(basename $0) -CREATE_TABLES_SQL="$SCRIPTS_DIR/exported/create-tables.sql" DESIGN_PNG="$SCRIPTS_DIR/exported/design.png" DESIGN_FILE="$SCRIPTS_DIR/design.dbm" @@ -104,25 +103,6 @@ while [[ $# -gt 0 ]]; do done - -if [ ! "$RERUN" = 'true' ]; then - if [ "$EXPORT" = 'true' ]; then - if ! command -v "pgmodeler-cli" &> /dev/null; then - echo "Could not find pgmodeler-cli, continuing with existing sql file" - sleep 1 - else - echo 'exporting fresh sql file from design' - pgmodeler-cli --input $DESIGN_FILE --export-to-file --output $CREATE_TABLES_SQL \ - && pgmodeler-cli --input $DESIGN_FILE --export-to-png --output $DESIGN_PNG; - PGEXPORT_EXIT_CODE=$? - fi - fi - - if [ "$ONLY_EXPORT" = 'true' ]; then - exit $PGEXPORT_EXIT_CODE; - fi -fi - if [ -n "$ENV_FILE" ]; then source "$ENV_FILE" fi diff --git a/package.json b/package.json index f53cacae5..bc0a42078 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "start:dev:ND": "node app/main.js", "start:dev:local": "(export RCT_DB_HOST=${RCT_DB_HOST:-localhost}; bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && npm run start:dev')", "deploy:db:local": "./database/setup-db.sh --env ./docker/dev.env", - "dev": "./rctmake prune,db:export,run,app:attach,stop --target dev", + "dev": "./rctmake prune,run,app:attach,stop --target dev", "idev": "node -e \"app = require('./app/application.js'); const { databaseManager: dbm } = app\" -i", "node-dev-env": "(export RCT_DB_HOST=$(docker inspect o2rct_database-dev -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'); bash -c 'set -o allexport && ls && source ./docker/dev.env && set +o allexport && node')", "test": "./rctmake prune,run --target test", "prune": "./rctmake prune", "app:attach": "./rctmake app:attach", "app:battach": "./rctmake app:battach", - "db:check": "./rctmake prune,db:export,run,follow -t dev -S o2rct_database-dev ", + "db:check": "./rctmake prune,run,follow -t dev -S o2rct_database-dev ", "db:attach": "./rctmake db:attach", "db:battach": "./rctmake db:battach", "db:clean": "./rctmake db:clean", diff --git a/rctmake b/rctmake index 418bc2a24..004ca6a6f 100755 --- a/rctmake +++ b/rctmake @@ -71,21 +71,20 @@ Usage: 9. db:attach - run psql on $DB_CONTRAINER_NAME 10. db:battach - run bash on $DB_CONTRAINER_NAME - 11. db:(export|ex) - export db sql definition from pgmodeler design $ITWILLBEDELETED - 12. db:clean | db:truncate - truncate database in db container - 13. db:ip - print db container ipv4 address - 14. db:(counts|ct) - print statistics of data in each table in db + 11. db:clean | db:truncate - truncate database in db container + 12. db:ip - print db container ipv4 address + 13. db:(counts|ct) - print statistics of data in each table in db - 15. dump:(make|mk) - make dump of current database (in docker container) data, + 14. dump:(make|mk) - make dump of current database (in docker container) data, need option -F|--dump-file to specify dump file relative path e.g.: ./$SCRIPT_NAME dump -F dump_file - 16. dump:(list|ls) - print list cached dumps - 17. dump:tree - print tree of cached dumps - 18. dump:(remove|rm) -F|--dump-file - remove dump from cache specified by the flag - 19. dump:(restore|re) -F|--dump-file - restore data from dump specified by the flag + 15. dump:(list|ls) - print list cached dumps + 16. dump:tree - print tree of cached dumps + 17. dump:(remove|rm) -F|--dump-file - remove dump from cache specified by the flag + 18. dump:(restore|re) -F|--dump-file - restore data from dump specified by the flag e.g.: ./$SCRIPT_NAME restore -F dump_file - 20. dump:(export|ex) -A|--archive-name - export cached dump to tar.gz archive specified by the flag - 21. dump:(import|im) -A|--archive-name - import dumps from tar.gz archvie specified by the flag ito cache + 19. dump:(export|ex) -A|--archive-name - export cached dump to tar.gz archive specified by the flag + 20. dump:(import|im) -A|--archive-name - import dumps from tar.gz archvie specified by the flag ito cache Other options: -S|--service - flag can be specified for run, follow, stop and prune stages. @@ -289,9 +288,6 @@ for stage in $STAGES; do docker exec -it $DB_CONTAINER_NAME /bin/bash; ;; - export|ex) - $PROJECT_DIR/database/setup-db.sh --only-export; - ;; clean | truncate) docker cp "$PROJECT_DIR/database/utils/delete-data.sql" "$DB_CONTAINER_NAME:$DB_WORKINGDIR/delete-data.sql" \ && docker exec $DB_CONTAINER_NAME psql -U $RCT_DB_USER -d $RCT_DB_NAME -f "$DB_WORKINGDIR/delete-data.sql"; From 830318a7b8dfb02cd99c8e43baf8177899f632fb Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:08:55 +0200 Subject: [PATCH 17/20] remove unexisting field from legacy view definition --- app/lib/database/views/data_passes_view.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/lib/database/views/data_passes_view.js b/app/lib/database/views/data_passes_view.js index f14cba4a2..31fae7f14 100644 --- a/app/lib/database/views/data_passes_view.js +++ b/app/lib/database/views/data_passes_view.js @@ -17,10 +17,7 @@ const data_passes_view = (query) => ` --dp.id dp.name, dp.description, - dp.jira, - dp.ml, dp.number_of_events, - dp.software_version, dp.size FROM data_passes AS dp WHERE dp.period_id = (SELECT id from periods WHERE name ='${query.index}') From 9f264cce95ad5c35231e531f211684bcd2c54237 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:40:18 +0200 Subject: [PATCH 18/20] amend views (some columns deleted) --- app/lib/alimonitor-services/MonalisaServiceMC.js | 14 +++++--------- .../database/views/anchorage_per_data_pass_view.js | 1 - app/lib/database/views/anchored_per_mc_view.js | 3 --- app/lib/database/views/mc_view.js | 1 - 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/app/lib/alimonitor-services/MonalisaServiceMC.js b/app/lib/alimonitor-services/MonalisaServiceMC.js index 54169c78d..fd86c16b9 100644 --- a/app/lib/alimonitor-services/MonalisaServiceMC.js +++ b/app/lib/alimonitor-services/MonalisaServiceMC.js @@ -46,10 +46,11 @@ class MonalisaServiceMC extends AbstractServiceSynchronizer { EndpointsFormatter.mcRaw(), this.responsePreprocess.bind(this), this.dataAdjuster.bind(this), - (r) => { - const { anchor_productions, anchor_passes } = r; - return r.period.year >= config.dataFromYearIncluding && anchor_productions.length != 0 && anchor_passes.length != 0; - // MC not anchored to any production so drop out + (simulation_pass) => { + const { anchor_productions, anchor_passes } = simulation_pass; + return simulation_pass.period.year >= config.dataFromYearIncluding + && anchor_productions.length != 0 && anchor_passes.length != 0; + // MC not anchored to any production or pass so drop out }, this.dbAction.bind(this), ); @@ -88,11 +89,6 @@ class MonalisaServiceMC extends AbstractServiceSynchronizer { } async dbAction(dbClient, d) { - const { anchor_productions, anchor_passes } = d; - if (anchor_productions.length == 0 || anchor_passes.length == 0) { - // MC not anchored to any production so drop out - return; - } d = Utils.adjusetObjValuesToSql(d); const { period } = d; const period_insert = diff --git a/app/lib/database/views/anchorage_per_data_pass_view.js b/app/lib/database/views/anchorage_per_data_pass_view.js index 8af64ffa7..cbccf8068 100644 --- a/app/lib/database/views/anchorage_per_data_pass_view.js +++ b/app/lib/database/views/anchorage_per_data_pass_view.js @@ -18,7 +18,6 @@ const anchorage_per_data_pass_view = (query) => ` sp.name, sp.description, sp.jira, - sp.ml, sp.pwg, sp.number_of_events FROM simulation_passes AS sp diff --git a/app/lib/database/views/anchored_per_mc_view.js b/app/lib/database/views/anchored_per_mc_view.js index fddd4e678..250d8dbe8 100644 --- a/app/lib/database/views/anchored_per_mc_view.js +++ b/app/lib/database/views/anchored_per_mc_view.js @@ -17,10 +17,7 @@ const anchored_per_mc_view = (query) => ` --dp.id dp.name, dp.description, - dp.jira, - dp.ml, dp.number_of_events, - dp.software_version, dp.size FROM data_passes AS dp INNER JOIN anchored_passes as aps diff --git a/app/lib/database/views/mc_view.js b/app/lib/database/views/mc_view.js index 6b606bcc9..1f165c6a3 100644 --- a/app/lib/database/views/mc_view.js +++ b/app/lib/database/views/mc_view.js @@ -18,7 +18,6 @@ const mc_view = (query) => ` sp.name, sp.description, sp.jira, - sp.ml, sp.pwg, sp.number_of_events FROM simulation_passes AS sp From cb3b797a7572e329bf3016c1f8fe338fa982f7b6 Mon Sep 17 00:00:00 2001 From: xsalonx <65893715+xsalonx@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:50:17 +0200 Subject: [PATCH 19/20] prune remanings of pgmodeler --- database/design.dbm | 888 ---------------------------- database/exported/create-tables.sql | 715 ---------------------- database/exported/design.png | Bin 567203 -> 0 bytes database/setup-db.sh | 30 +- hooks/pre-commit/db-design.sh | 10 - hooks/pre-commit/newlines.sh | 1 - 6 files changed, 1 insertion(+), 1643 deletions(-) delete mode 100644 database/design.dbm delete mode 100644 database/exported/create-tables.sql delete mode 100644 database/exported/design.png delete mode 100755 hooks/pre-commit/db-design.sh diff --git a/database/design.dbm b/database/design.dbm deleted file mode 100644 index 00ba2b96e..000000000 --- a/database/design.dbm +++ /dev/null @@ -1,888 +0,0 @@ - - - - - - - - - - - - - - - -