20220512000003-create-invoices.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { QueryInterface, DataTypes } from "sequelize";
  2. module.exports = {
  3. up: (queryInterface: QueryInterface) => {
  4. return queryInterface.createTable("Invoices", {
  5. id: {
  6. type: DataTypes.INTEGER,
  7. autoIncrement: true,
  8. primaryKey: true,
  9. allowNull: false
  10. },
  11. detail: {
  12. type: DataTypes.STRING,
  13. },
  14. status: {
  15. type: DataTypes.STRING,
  16. },
  17. value: {
  18. type: DataTypes.FLOAT
  19. },
  20. createdAt: {
  21. type: DataTypes.DATE,
  22. allowNull: false
  23. },
  24. updatedAt: {
  25. type: DataTypes.DATE,
  26. allowNull: false
  27. },
  28. dueDate: {
  29. type: DataTypes.STRING,
  30. },
  31. companyId: {
  32. type: DataTypes.INTEGER,
  33. references: { model: "Companies", key: "id" },
  34. onUpdate: "CASCADE",
  35. onDelete: "CASCADE"
  36. }
  37. });
  38. },
  39. down: (queryInterface: QueryInterface) => {
  40. return queryInterface.dropTable("Invoices");
  41. }
  42. };