sequelize-cli-typescript icon indicating copy to clipboard operation
sequelize-cli-typescript copied to clipboard

Generated migration imports failing

Open krlicmuhamed opened this issue 5 years ago • 3 comments

What you are doing?

I am trying to generate a model that has a migration with it

import {
    QueryInterface,
    SequelizeStatic,
} from 'sequelize';

export = {
    up: (queryInterface: QueryInterface, Sequelize: SequelizeStatic) => {
        return queryInterface.createTable('Devices', {
            id: {
                allowNull: false,
                autoIncrement: true,
                primaryKey: true,
                type: Sequelize.INTEGER
            },

            deviceName: {
                type: Sequelize.STRING
            },

            imei: {
                type: Sequelize.STRING
            },

            createdAt: {
                allowNull: false,
                type: Sequelize.DATE
            },

            updatedAt: {
                allowNull: false,
                type: Sequelize.DATE
            }
        });
    },

    down: (queryInterface: QueryInterface, Sequelize: SequelizeStatic) => {
        return queryInterface.dropTable('Devices');
    }
};

What do you expect to happen?

I expected SequelizeStatic to be working and to be declared

What is actually happening?

However, SequelizeStatic apparently doesn't exist, why is that? Image of the error Module '"../../node_modules/sequelize/types"' has no exported member 'SequelizeStatic'.ts(2305) Dialect: mysql / postgres / sqlite / mssql / any Database version: 9.5 Sequelize CLI version: 3.2.0-c Sequelize version: 5.22.3

krlicmuhamed avatar Dec 06 '20 12:12 krlicmuhamed

Same error.

@types/sequelize 4.28.9 typescript 4.2.4 sequelize 6.6.2 sequelize-cli-typescript 3.2.0c pg 8.6.0

marlongerson avatar May 20 '21 21:05 marlongerson

@krlicmuhamed @marlongerson @fredcy which do you have used to create a migration in typescript. I have tried the sequelize-cli migration:generate --name=sys-user but it does not work. It failed and throw me an error of invalid arguments.

Following is my .sequelizerc.

const path = require('path');

module.exports = {
  config: path.resolve("dist", "config", "db.config.js"),
  "models-path": path.resolve("src", "orm", "models"),
  'migrations-source-path': path.resolve('src', 'orm', 'migrations'),
  'migrations-compiled-path': path.resolve('dist', 'orm', 'migrations'), 
  'seeders-source-path': path.resolve('src', 'orm', 'seeders'),
  'seeders-compiled-path': path.resolve('dist', 'orm', 'seeders'),
};

Can anyone put some light on my issue?

dipakchavda2912 avatar Aug 28 '22 18:08 dipakchavda2912