Skip to content

Align DB schema with TypeORM entities - #203

Merged
buzz-code merged 1 commit into
mainfrom
claude/align-db-typeorm
Oct 6, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/align-db-typeorm

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Summary

typeorm migration:generate on main reported drift between the entities and the schema the migrations build. This PR adds one migration, AlignSchemaWithEntities1791306682943, generated by TypeORM (with the hardcoded DB name swapped for dbName, like other migrations):

  • teacher_reported_today view — the migration-created view lists lessonReferenceId before klassReferenceId. The entity's generated SQL has the opposite order. No change to the data, only the stored SQL text.
  • attendance_cleanup_rules — lesson_id and klass_id are NOT NULL in the DB but nullable: true in the entity. active is tinyint DEFAULT '1' vs entity tinyint(1) DEFAULT 1.

No entity or app code changes.

Testing

Local MySQL 8 loaded from db/data.sql plus all migrations:

  • typeorm:run → typeorm:revert → typeorm:run all succeed.
  • After the run, migration:generate --dryrun produces no queries (zero drift).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld


Generated by Claude Code

teacher_reported_today view column order and attendance_cleanup_rules
lesson_id/klass_id nullability + active column type, so
migration:generate reports no drift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Migration correctly applies and reverses documented schema alignment.

Review effort: Balanced
Findings: None

What changed in this PR

Adds migration aligning MySQL schema and TypeORM metadata.

Changes:

  • Makes cleanup-rule keys nullable and normalizes boolean type.
  • Reorders view columns and syncs metadata.
File Description
server/​src/​migrations/​1791306682943-AlignSchemaWithEntities.ts Aligns table and view schemas with entities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@buzz-code
buzz-code merged commit bfd140f into main Oct 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants