flexxnn / sequelize-auto-migrations

Migration generator && runner for sequelize
MIT License
258 stars 166 forks source link

Class constructor cannot be invoked without new #78

Open kaykhancheckpoint opened 4 years ago

kaykhancheckpoint commented 4 years ago

I am using sequalize and I'm trying to run auto migrations with the following library: https://github.com/flexxnn/sequelize-auto-migrations with NODE_ENV=development npx sequelize-auto-migrations --name initial but i get the following error:

Class constructor Authentication cannot be invoked without 'new'

const Sequelize = require('sequelize');
const sequelize = require('../../config/database');
const { serializeModel } = require('../utils/serializeRelationships');
const { Op } = require('sequelize');

const hooks = {};

const tableName = 'authentication';

const defaultScope = {};

class Authentication extends Sequelize.Model {}

Authentication.init({
    id: {
        type: Sequelize.UUID,
        primaryKey: true,
    },
    dType: {
        type: Sequelize.STRING,
        field: 'dtype',
    },
    serviceId: {
        type: Sequelize.STRING,
        field: 'service_id',
    },
    session: {
        type: Sequelize.STRING,
    },
    createdAt: {
        type: Sequelize.DATE,
        field: 'created_at',
    },
    updatedAt: {
        type: Sequelize.DATE,
        field: 'updated_at',
    },
}, {
    sequelize, defaultScope, scopes: {}, hooks, tableName, timestamps: true,
});

Authentication.prototype.toJSON = function toJSON() {
    return serializeModel(this);
};

module.exports = Authentication;

node: v12.16.3

Im not using babel or anything else.