1.04-labor-hours.js 1005 B

1234567891011121314151617181920212223242526
  1. module.exports = {
  2. version: 1.04,
  3. name: 'Labor Hours',
  4. description: 'Adds an hours field to labor and workday, moves previously separated hours into that field.',
  5. up: async (queryInterface, Sequelize) => {
  6. await queryInterface.addColumn('labors', 'hours', Sequelize.DOUBLE)
  7. await queryInterface.addColumn('workdays', 'hours', Sequelize.DOUBLE)
  8. await queryInterface.addColumn('labors', 'doubletimeHours', Sequelize.DOUBLE)
  9. await queryInterface.addColumn('workdays', 'doubletimeHours', Sequelize.DOUBLE)
  10. await queryInterface.sequelize.query(`
  11. UPDATE labors
  12. SET hours = COALESCE(overtimeHours, 0) + COALESCE(regularHours, 0),
  13. overtimeHours = null,
  14. regularHours = null
  15. WHERE hours is null
  16. `)
  17. await queryInterface.sequelize.query(`
  18. UPDATE workdays
  19. SET hours = COALESCE(overtimeHours, 0) + COALESCE(regularHours, 0),
  20. overtimeHours = null,
  21. regularHours = null
  22. WHERE hours is null
  23. `)
  24. return 1.04
  25. }
  26. }