Skip to content

Seed bulkinsert requires createdAt, updatedAt by default (not documented) #790

@izznogooood

Description

@izznogooood

What you are doing?

Creating seeds for cli created models.

'use strict';

module.exports = {
    up: (queryInterface, Sequelize) => {
        /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.bulkInsert('People', [{
        name: 'John Doe',
        isBetaMember: false
      }], {});
    */
        return queryInterface.bulkInsert(
            'Languages',
            [
                {
                    id: 1,
                    name: 'english',
                    createdAt: new Date(),
                    updatedAt: new Date()
                },
                {
                    id: 2,
                    name: 'norwegian',
                    createdAt: new Date(),
                    updatedAt: new Date()
                }
            ],
            {}
        );
    },
    
    down: (queryInterface, Sequelize) => {
        /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.bulkDelete('People', null, {});
    */
    }
};

What do you expect to happen?

Expeted to work like the examples (without createdAt, updatedAt)

What is actually happening?

Need createdAt, updatedAt.

Output, either JSON or SQL

Dialect: sqlite / postgres
Database version: 3 / 10.3
Sequelize CLI version: 5.4.0
Sequelize version: 5.8.7

Suggestion

If you want I could update the docs to reflect this?
/ or
Take a stab at adding this automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions