Search code examples
node.jssqlitesequelize.jsseedingsequelize-cli

sequelize seed unable to insert the data in SQLite


I am trying to insert the dummy data using sequelize-cli command

sequelize db:seed --seed seeders/20170212081140-subject_tags.js

here is my config file

{
  "development": {
    "username": "root",
    "password": null,
    "database": "database_development",
    "host": "127.0.0.1",
    "dialect": "sqlite",
    "seederStorage": "sequelize",
    "storage": "./test"
  }
}

and here my seeder file

use strict';

module.exports = {
  up: function(queryInterface, Sequelize) {

    return 
      queryInterface.bulkUpdate('subject_tags', [

      {
        tag: 'agricultural-sciences',
        tag_description: '',
        subject_category: 'biological_&_medical_sciences',
        createdAt: new Date(),
        updatedAt: new Date()
      }, {
        tag: 'biochemistry',
        tag_description: '',
        subject_category: 'biological_&_medical_sciences',
        createdAt: new Date(),
        updatedAt: new Date()
      }, {
        tag: 'bioinformatics',
        tag_description: '',
        subject_category: 'biological_&_medical_sciences',
        createdAt: new Date(),
        updatedAt: new Date()
      }
    ] , {});
  },

  down: function(queryInterface, Sequelize) {
     return 
      queryInterface.bulkDelete('subject_tags', null, {});

  }
}; 

Though I am getting the status

Using environment "development".
== 20170212081140-subject_tags: migrating =======
== 20170212081140-subject_tags: migrated (0.053s)

I tried bulkCreate and bulkInsert in the seed file , all of them run successful, but data does not get inserted into the table the data does not get inserted. Is I am doing something wrong?


Solution

  • It seems to be issue with sequlizer, after return statement it unable to handle space with newline character

    module.exports = {
      up: function(queryInterface, Sequelize) {
        //old code
        //return 
        //  queryInterface.bulkUpdate('subject_tags', [
    
        //new code
        return queryInterface.bulkUpdate('subject_tags', [
        //.........