Open dylanlingelbach opened 7 years ago
We use ARRAY types and are testing out using sequelize-auto-migrations. ARRAY types don't generate correctly.
ARRAY
sequelize-auto-migrations
Minimal repro below:
'use strict';
const Sequelize = require('sequelize');
module.exports = function (sequelize) { const Test = sequelize.define('test', { array: { type: Sequelize.ARRAY(Sequelize.TEXT), allowNull: false, defaultValue: [] } }, { });
return Test;
};
2. Generate the migration **Expected:** Syntactically valid migration generated
var Sequelize = require('sequelize');
/**
**/
var info = { "revision": 2, "name": "testSchema", "created": "2017-08-02T16:42:10.042Z", "comment": "" };
var migrationCommands = [{ fn: "createTable", params: [ "tests", { "id": { "type": Sequelize.INTEGER, "autoIncrement": true, "primaryKey": true, "allowNull": false }, "array": { "type": Sequelize.ARRAY(Sequelize.TEXT), // This line is wrong in the generated migration "defaultValue": [], "allowNull": false }, "createdAt": { "type": Sequelize.DATE, "allowNull": false }, "updatedAt": { "type": Sequelize.DATE, "allowNull": false } }, {} ] } ];
module.exports = { pos: 0, up: function(queryInterface, Sequelize) { var index = this.pos; return new Promise(function(resolve, reject) { function next() { if (index < migrationCommands.length) { let command = migrationCommands[index]; console.log("[#"+index+"] execute: " + command.fn); index++; queryInterface[command.fn].apply(queryInterface, command.params).then(next, reject); } else resolve(); } next(); }); }, info: info };
**Actual:**
var migrationCommands = [{ fn: "createTable", params: [ "tests", { "id": { "type": Sequelize.INTEGER, "autoIncrement": true, "primaryKey": true, "allowNull": false }, "array": { "type": TEXT[], // This syntax is incorrect "defaultValue": [], "allowNull": false }, "createdAt": { "type": Sequelize.DATE, "allowNull": false }, "updatedAt": { "type": Sequelize.DATE, "allowNull": false } }, {} ] } ];
Thank you so much for this package. It's been a big help so far.
This is a great library. But a bug with the type of ARRAY does not allow it to use with PostgreSQL. Are there any plans to fix this?
Up
We use
ARRAY
types and are testing out usingsequelize-auto-migrations
.ARRAY
types don't generate correctly.Minimal repro below:
const Sequelize = require('sequelize');
module.exports = function (sequelize) { const Test = sequelize.define('test', { array: { type: Sequelize.ARRAY(Sequelize.TEXT), allowNull: false, defaultValue: [] } }, { });
};
'use strict';
var Sequelize = require('sequelize');
/**
**/
var info = { "revision": 2, "name": "testSchema", "created": "2017-08-02T16:42:10.042Z", "comment": "" };
var migrationCommands = [{ fn: "createTable", params: [ "tests", { "id": { "type": Sequelize.INTEGER, "autoIncrement": true, "primaryKey": true, "allowNull": false }, "array": { "type": Sequelize.ARRAY(Sequelize.TEXT), // This line is wrong in the generated migration "defaultValue": [], "allowNull": false }, "createdAt": { "type": Sequelize.DATE, "allowNull": false }, "updatedAt": { "type": Sequelize.DATE, "allowNull": false } }, {} ] } ];
module.exports = { pos: 0, up: function(queryInterface, Sequelize) { var index = this.pos; return new Promise(function(resolve, reject) { function next() { if (index < migrationCommands.length) { let command = migrationCommands[index]; console.log("[#"+index+"] execute: " + command.fn); index++; queryInterface[command.fn].apply(queryInterface, command.params).then(next, reject); } else resolve(); } next(); }); }, info: info };
'use strict';
var Sequelize = require('sequelize');
/**
**/
var info = { "revision": 2, "name": "testSchema", "created": "2017-08-02T16:42:10.042Z", "comment": "" };
var migrationCommands = [{ fn: "createTable", params: [ "tests", { "id": { "type": Sequelize.INTEGER, "autoIncrement": true, "primaryKey": true, "allowNull": false }, "array": { "type": TEXT[], // This syntax is incorrect "defaultValue": [], "allowNull": false }, "createdAt": { "type": Sequelize.DATE, "allowNull": false }, "updatedAt": { "type": Sequelize.DATE, "allowNull": false } }, {} ] } ];
module.exports = { pos: 0, up: function(queryInterface, Sequelize) { var index = this.pos; return new Promise(function(resolve, reject) { function next() { if (index < migrationCommands.length) { let command = migrationCommands[index]; console.log("[#"+index+"] execute: " + command.fn); index++; queryInterface[command.fn].apply(queryInterface, command.params).then(next, reject); } else resolve(); } next(); }); }, info: info };