Skip to content

Commit

Permalink
feat: added Sequelize seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
mvegter committed Apr 28, 2020
1 parent bcdfb40 commit b3301c7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ class SequelizeDatabase extends Database {
* @returns {Promise} Promise object represents the outcome.
*/
async seed() {
// This is a no-op method
const umzug = new Umzug({
migrations: {
params: [this.sequelize.getQueryInterface(), Sequelize],
path: path.join(__dirname, 'seeders'),
},
storage: 'none',
});

return umzug.up();
}
}

Expand Down
34 changes: 34 additions & 0 deletions lib/database/seeders/20200426144121-seeder-skeleton.js
Original file line number Diff line number Diff line change
@@ -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.
*/

module.exports = {
up: (queryInterface, _Sequelize) => queryInterface.bulkInsert('Logs', [
{
title: 'First entry',
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: 'Second entry',
createdAt: new Date(),
updatedAt: new Date(),
},
{
title: 'Third entry',
createdAt: new Date(),
updatedAt: new Date(),
},
]),

down: (queryInterface, _Sequelize) => queryInterface.bulkDelete('Logs', null, {}),
};

0 comments on commit b3301c7

Please sign in to comment.