chore: relocate backend into apps/api ahead of monorepo merge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 12:20:40 +08:00
co-authored by Claude Sonnet 5
parent af44598df6
commit eaa6d2276a
388 changed files with 0 additions and 13998 deletions
@@ -0,0 +1,41 @@
'use strict';
// Raw SQL — Sequelize's createTable() wraps ENUM creation in a `DO $$...$$`
// block for idempotency, which CockroachDB rejects ("CREATE TYPE usage
// inside a function definition is not supported"). STRING + CHECK instead,
// same pattern used throughout this schema for CRDB compatibility.
module.exports = {
async up(queryInterface) {
await queryInterface.sequelize.query(`
CREATE TABLE completion_requirements (
requirement_id UUID PRIMARY KEY,
entity_type STRING NOT NULL,
entity_id BIGINT NOT NULL,
type STRING NOT NULL,
min_percent INTEGER NULL,
button_label STRING NULL,
is_required BOOLEAN NOT NULL DEFAULT true,
"order" INTEGER NOT NULL DEFAULT 0,
"createdBy" BIGINT NULL,
"updatedBy" BIGINT NULL,
"deletedBy" BIGINT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deletedAt" TIMESTAMPTZ NULL,
CONSTRAINT check_cr_entity_type CHECK (entity_type IN ('course', 'unit', 'lesson')),
CONSTRAINT check_cr_type CHECK (type IN ('read_all_content', 'pass_quiz', 'watch_percent', 'manual_complete', 'watch_video', 'listen_audio'))
);
`);
await queryInterface.sequelize.query(
`CREATE INDEX idx_cr_entity_type_entity_id ON completion_requirements (entity_type, entity_id);`
);
await queryInterface.sequelize.query(
`CREATE INDEX idx_cr_type ON completion_requirements (type);`
);
},
async down(queryInterface) {
await queryInterface.sequelize.query(`DROP TABLE IF EXISTS completion_requirements;`);
},
};