Skip to content

Commit

Permalink
feat: Added run model and migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nino van Galen committed May 8, 2020
1 parent 801aaf6 commit a9a3daa
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class SequelizeDatabase extends IDatabase {
collate: 'utf8mb4_unicode_ci',
},
logging: this.logger.debug.bind(this.logger),
define: {
underscored: true,
},
});
}

Expand Down
72 changes: 72 additions & 0 deletions lib/database/migrations/20200505214213-create-run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* @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.
*/

module.exports = {
up: (queryInterface, Sequelize) => queryInterface.createTable('Runsinit', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
time_o2_start: {
type: Sequelize.DATE,
},
time_o2_end: {
type: Sequelize.DATE,
},
time_trg_start: {
type: Sequelize.DATE,
},
time_trg_end: {
type: Sequelize.DATE,
},
activity_id: {
type: Sequelize.CHAR,
},
run_type: {
type: Sequelize.ENUM('physics', 'cosmics', 'technical'),
},
run_quality: {
type: Sequelize.ENUM('good', 'bad', 'unknown'),
},
n_detectors: {
type: Sequelize.INTEGER,
},
n_flps: {
type: Sequelize.INTEGER,
},
n_epns: {
type: Sequelize.INTEGER,
},
n_subtimeframes: {
type: Sequelize.INTEGER,
},
bytes_read_out: {
type: Sequelize.INTEGER,
},
bytes_timeframe_builder: {
type: Sequelize.INTEGER,
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
},
}),

down: (queryInterface, _Sequelize) => queryInterface.dropTable('Runsinit'),
};
4 changes: 3 additions & 1 deletion lib/database/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* or submit itself to any jurisdiction.
*/

const Log = require('./Log');
const Log = require('./log');
const Run = require('./run');

module.exports = (sequelize, Sequelize) => ({
Log: Log(sequelize, Sequelize),
Run: Run(sequelize, Sequelize),
});
32 changes: 32 additions & 0 deletions lib/database/models/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @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.
*/

module.exports = (sequelize, Sequelize) => {
const Run = sequelize.define('Run', {
timeO2Start: Sequelize.DATE,
timeO2End: Sequelize.DATE,
timeTrgStart: Sequelize.DATE,
timeTrgEnd: Sequelize.DATE,
activityId: Sequelize.CHAR,
runType: Sequelize.ENUM('physics', 'cosmics', 'technical'),
runQuality: Sequelize.ENUM('good', 'bad', 'unknown'),
nDetectors: Sequelize.INTEGER,
nFlps: Sequelize.INTEGER,
nEpns: Sequelize.INTEGER,
nSubtimeframes: Sequelize.INTEGER,
bytesReadOut: Sequelize.INTEGER,
bytesTimeframe_builder: Sequelize.INTEGER,
}, {});

return Run;
};

0 comments on commit a9a3daa

Please sign in to comment.