create-table.js 1006 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. /** @type {import('sequelize-cli').Migration} */
  3. module.exports = {
  4. async up (queryInterface, Sequelize) {
  5. await queryInterface.createTable('<%= tableName %>', {
  6. id: {
  7. allowNull: false,
  8. autoIncrement: true,
  9. primaryKey: true,
  10. type: Sequelize.INTEGER
  11. },
  12. <% attributes.forEach(function(attribute) { %>
  13. <%= attribute.fieldName %>: {
  14. type: Sequelize.<%= attribute.dataFunction ? `${attribute.dataFunction.toUpperCase()}(Sequelize.${attribute.dataType.toUpperCase()})` : attribute.dataValues ? `${attribute.dataType.toUpperCase()}(${attribute.dataValues})` : attribute.dataType.toUpperCase() %>
  15. },
  16. <% }) %>
  17. <%= createdAt %>: {
  18. allowNull: false,
  19. type: Sequelize.DATE
  20. },
  21. <%= updatedAt %>: {
  22. allowNull: false,
  23. type: Sequelize.DATE
  24. }
  25. });
  26. },
  27. async down (queryInterface, Sequelize) {
  28. await queryInterface.dropTable('<%= tableName %>');
  29. }
  30. };