Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function getMigrator(type, args) {
migrations: {
params: [sequelize.getQueryInterface(), Sequelize],
path: helpers.path.getPath(type),
pattern: /\.c?js$/,
pattern: /\.(cjs|js|ts)$/,
},
});

Expand Down
19 changes: 18 additions & 1 deletion test/db/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const _ = require('lodash');
const config = _.assign({}, helpers.getTestConfig(), options.config);
let configContent = JSON.stringify(config);

if (!migrationFile.match(/\.cjs$/)) {
if (!migrationFile.match(/\.(cjs|ts)$/)) {
migrationFile = migrationFile + '.js';
}
if (flag.match(/config\.js$/)) {
Expand Down Expand Up @@ -152,6 +152,23 @@ const _ = require('lodash');
});
});

describe('migrations with ts extension', () => {
it('correctly migrates', function (done) {
const self = this;
prepare(
() => {
helpers.readTables(self.sequelize, (tables) => {
expect(tables.sort()).to.contain('Typescript');
done();
});
},
{
migrationFile: 'ts/*createTypescript.ts',
}
);
});
});

describe('custom meta table name', () => {
it('correctly uses the defined table name', function (done) {
const self = this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = {
up: async (queryInterface, DataTypes) => {
await queryInterface.createTable('Typescript', {
title: DataTypes.STRING,
body: DataTypes.TEXT,
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('Typescript');
},
};