-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added logruns and add associations migration
- Loading branch information
Nino van Galen
committed
May 8, 2020
1 parent
ea979d3
commit bf208e8
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
40
lib/database/migrations/20200507230653-add-associations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')), | ||
|
||
}; |