mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// task_requirements.type IS a real DB enum (task_requirement_type), despite
|
|
// 20260709000001-add-requires-review-and-prompt-to-task-requirements.js's comment
|
|
// claiming otherwise ("Sequelize enforces the ENUM only at the application layer
|
|
// for this table, so no constraint migration is needed") — that assumption was
|
|
// wrong. submit_text and pass_quiz were added to the Sequelize model (task.mdl.js)
|
|
// and the admin RequirementBuilder.jsx UI at the same time, but never to the actual
|
|
// DB enum, so creating/querying either type has been failing with
|
|
// "invalid input value for enum task_requirement_type" ever since (found while
|
|
// verifying the new completion_requirements feature's task auto-complete path,
|
|
// which happened to be the first thing to actually query a pass_quiz-typed
|
|
// TaskRequirement against this DB).
|
|
//
|
|
// ALTER TYPE ... ADD VALUE (not CREATE TYPE) is a plain top-level statement, not
|
|
// wrapped in Sequelize's problematic DO $$...$$ block, so this runs fine as a
|
|
// normal migration — no raw-SQL-outside-migrations workaround needed here.
|
|
|
|
module.exports = {
|
|
async up(queryInterface) {
|
|
await queryInterface.sequelize.query(
|
|
`ALTER TYPE task_requirement_type ADD VALUE IF NOT EXISTS 'submit_text'`
|
|
);
|
|
await queryInterface.sequelize.query(
|
|
`ALTER TYPE task_requirement_type ADD VALUE IF NOT EXISTS 'pass_quiz'`
|
|
);
|
|
},
|
|
|
|
// Postgres/CockroachDB cannot remove a value from an enum type — down is a no-op.
|
|
async down() {},
|
|
};
|