You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
/* This file is auto-generated using https://github.com/harish2704/sequelize-migration-generator. */
|
|
|
|
'use strict';
|
|
|
|
module.exports = {
|
|
up: function (queryInterface, Sequelize) {
|
|
return queryInterface.createTable('<%- @model.tableName %>', {
|
|
<% for field in @model.fields : %>
|
|
<%- field.name %>: {
|
|
type: Sequelize.<%- field.type %><%- field.values %><%- field.length %><%- '.UNSIGNED' if field.unsigned %>,
|
|
<% if field.references?.model : %>
|
|
references: <%- JSON.stringify field.references %>,
|
|
<% end %>
|
|
<% for opt in @fieldOpts : %>
|
|
<% if not field[opt].isEmpty() : %>
|
|
<%- opt %> : <%- field[opt] %>,
|
|
<% end %>
|
|
<% end %>
|
|
},
|
|
|
|
<% end %>
|
|
})<% if ( Object.keys @model.uniqueKeys ).length : %>
|
|
<% for keyName, keyOpts of @model.uniqueKeys : %>
|
|
|
|
.then( function(){
|
|
return queryInterface.addIndex(
|
|
'<%- @model.tableName %>',
|
|
<%- JSON.stringify keyOpts.fields %>,
|
|
{
|
|
indexName: '<%- keyName %>',
|
|
indicesType: 'UNIQUE'
|
|
}
|
|
)
|
|
<% end %>
|
|
})<% end %>;
|
|
},
|
|
|
|
down: function (queryInterface, Sequelize) {
|
|
return queryInterface.dropTable( '<%- @model.tableName %>' );
|
|
}
|
|
};
|
|
|
|
|