20191202014433-create_equipments_table.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict'
  2. module.exports = {
  3. /**
  4. * @param {Types} Sequelize
  5. */
  6. up: (queryInterface, Sequelize) => {
  7. return queryInterface.createTable('equipments', {
  8. id: {
  9. primaryKey: true,
  10. autoIncrement: true,
  11. type: Sequelize.BIGINT.UNSIGNED
  12. },
  13. name: {
  14. allowNull: false,
  15. type: Sequelize.STRING(30)
  16. },
  17. current_user_id: {
  18. type: Sequelize.BIGINT.UNSIGNED,
  19. references: {
  20. model: {
  21. tableName: 'users'
  22. },
  23. key: 'id'
  24. }
  25. }
  26. })
  27. /*
  28. Add altering commands here.
  29. Return a promise to correctly handle asynchronicity.
  30. Example:
  31. return queryInterface.createTable('users', { id: Sequelize.INTEGER });
  32. */
  33. },
  34. down: (queryInterface, Sequelize) => {
  35. return queryInterface.dropTable('equipments')
  36. /*
  37. Add reverting commands here.
  38. Return a promise to correctly handle asynchronicity.
  39. Example:
  40. return queryInterface.dropTable('users');
  41. */
  42. }
  43. }