continued

This commit is contained in:
Ccjcarkbla
2026-07-02 21:34:54 -04:00
parent 1d7317b74f
commit 95c217dbfe
3 changed files with 256 additions and 0 deletions
@@ -0,0 +1,28 @@
'use strict';
// Workouts, CrossfitWorkouts, and Timers were raw SQL tables in V1 — no updatedAt.
// Sequelize requires updatedAt by default; without this column any write to these
// tables fails. Backfill with createdAt so existing rows have a valid timestamp.
module.exports = {
async up(queryInterface, Sequelize) {
for (const table of ['Workouts', 'CrossfitWorkouts', 'Timers']) {
const cols = await queryInterface.describeTable(table).catch(() => null);
if (!cols || cols['updatedAt']) continue;
await queryInterface.addColumn(table, 'updatedAt', {
type: Sequelize.DATE,
allowNull: true,
});
await queryInterface.sequelize.query(
`UPDATE "${table}" SET "updatedAt" = "createdAt"`
);
}
},
async down(queryInterface) {
for (const table of ['Workouts', 'CrossfitWorkouts', 'Timers']) {
await queryInterface.removeColumn(table, 'updatedAt').catch(() => {});
}
},
};