不要怂,就是干,撸起袖子干!

Commit 4de34c55 by Simon Schick Committed by GitHub

fix(sync): handle alter correctly with underscored/aliased columns (#10872)

1 parent 5767fbac
...@@ -1296,7 +1296,7 @@ class Model { ...@@ -1296,7 +1296,7 @@ class Model {
const removedConstraints = {}; const removedConstraints = {};
_.each(attributes, (columnDesc, columnName) => { _.each(attributes, (columnDesc, columnName) => {
if (!columns[columnName]) { if (!columns[columnName] && !columns[attributes[columnName].field]) {
changes.push(() => this.QueryInterface.addColumn(this.getTableName(options), attributes[columnName].field || columnName, attributes[columnName])); changes.push(() => this.QueryInterface.addColumn(this.getTableName(options), attributes[columnName].field || columnName, attributes[columnName]));
} }
}); });
......
...@@ -1120,6 +1120,20 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -1120,6 +1120,20 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
}); });
}); });
it('handles alter: true with underscore correctly', function() {
this.sequelize.define('access_metric', {
user_id: {
type: DataTypes.INTEGER
}
}, {
underscored: true
});
return this.sequelize.sync({
alter: true
});
});
describe("doesn't emit logging when explicitly saying not to", () => { describe("doesn't emit logging when explicitly saying not to", () => {
afterEach(function() { afterEach(function() {
this.sequelize.options.logging = false; this.sequelize.options.logging = false;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!