Skip to content

Commit

Permalink
feat: Added logruns and add associations migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nino van Galen committed May 8, 2020
1 parent ea979d3 commit bf208e8
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/database/migrations/20200507202304-LogRuns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @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('log_runs', {
log_id: {
primaryKey: true,
type: Sequelize.INTEGER,
allowNull: false,
},
run_id: {
primaryKey: true,
type: Sequelize.INTEGER,
allowNull: false,
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
},
}),

down: (queryInterface, _Sequelize) => queryInterface.dropTable('log_runs'),
};
40 changes: 40 additions & 0 deletions lib/database/migrations/20200507230653-add-associations.js
Original file line number Diff line number Diff line change
@@ -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.
*/

module.exports = {
up: (queryInterface, Sequelize) => queryInterface.addColumn('logs', 'user_id', {
type: Sequelize.INTEGER,
references: {
model: 'users',
key: 'id',
},
allowNull: false,
}).then(() => queryInterface.addColumn('logs', 'root_log_id', {
type: Sequelize.INTEGER,
references: {
model: 'logs',
key: 'id',
},
})).then(() => queryInterface.addColumn('logs', 'parent_log_id', {
type: Sequelize.INTEGER,
references: {
model: 'logs',
key: 'id',
},
})),

down: (queryInterface, _Sequelize) => queryInterface.removeColumn('logs', 'user_id')
.then(() => queryInterface.removeColumn('logs', 'root_log_id'))
.then(() => queryInterface.removeColumn('logs', 'parent_log_id')),

};

0 comments on commit bf208e8

Please sign in to comment.