Files
The-transit-Project/.github/agents/azure-project-integrate/references/migrations.md
T
Sven laptop 635a130f0b
Build and Push Docker Images / detect-changes (push) Successful in 11s
Build and Push Docker Images / build-auth-api (push) Successful in 1m0s
Build and Push Docker Images / build-employee-api (push) Successful in 1m2s
Build and Push Docker Images / build-transit-api (push) Successful in 1m1s
Build and Push Docker Images / build-error-log-api (push) Successful in 1m5s
Build and Push Docker Images / build-admin-ui (push) Successful in 1m13s
Build and Push Docker Images / build-monitoring-ui (push) Successful in 1m15s
Build and Push Docker Images / deploy-test-node (push) Successful in 3s
──────
### Summary of Changes
  1. Documentation Consolidation:
      • Relocated the docs/ folder and all repository .md files (README.md, DEPLOYMENT.md, DOCKER_README.md,
      DOMAINS_README.md, GETTING_STARTED.md, CI_CD_PORTAINER_GUIDE.md, ADMIN_DEPLOYMENT_SUMMARY.md,
      SECURITY_PRIVATE_FILES.md, handoff.md, azure-project-plan.md, plus service-specific READMEs) into .
      • Updated document links in README.md.
  2. AI Agent Project Map:
      • Created PROJECT_MAP.md in the project root containing complete architecture diagrams, service specs, ports, DB
      schemas, environment variables, and developer workflows.
      • Added PROJECT_MAP.md to .gitignore.
  3. Monitoring UI & Infrastructure Integration:
      • Added monitoring_ui service to docker-compose.yml (port 5175).
      • Configured Gitea workflow docker-build.yml for monitoring_ui builds.
      • Added CORS middleware headers in index.js.
      • Added nginx.conf copy step in Dockerfile.

  ──────
  ### Recommended Commit Message

    docs: consolidate project documentation into monitoring_ui and add agent project map

    - Move all markdown documentation files and docs/ folder into monitoring_ui/docs/
    - Update documentation hub index (monitoring_ui/docs/README.md) with relative paths
    - Generate comprehensive AI agent reference map (PROJECT_MAP.md) in repository root
    - Add PROJECT_MAP.md and monitoring_ui build output/env overrides to .gitignore
    - Integrate monitoring_ui service into docker-compose.yml and Gitea CI workflow
    - Configure CORS handling in employee_api for monitoring dashboard access
    ──────
  ### Alternative Short Commit Message

    refactor(docs): move docs to monitoring_ui and create AI agent PROJECT_MAP.md
2026-09-20 23:33:55 +02:00

3.0 KiB

Important: This skill provides guidance and recommended instructions to assist the AI system. Outputs are not guaranteed to be complete, correct, secure, or applicable to every scenario. Results should be reviewed and validated by a human before being applied. The AI model may choose not to follow all instructions exactly, and additional verification may be required.

Schema Migrations (NO seed data)

Read at Step 1. Canonical guidance for creating SQL / PostgreSQL schema migrations during integration. Schema only — never seed data.


The one hard rule

You create structure, not content. Allowed: CREATE TABLE, ALTER TABLE, constraints, indexes, the migration runner. Forbidden: INSERT, demo rows, and any file/folder/function named seed, seeds, seed-data, fixtures. If the scaffold already produced seed files, leave them where they are — do not extend, run, or depend on them.


Per-stack migration tool

Stack Tool Create Apply Roll back
Node.js / TypeScript Knex knex migrate:make <name> knex migrate:latest knex migrate:rollback
Python Alembic alembic revision -m "<name>" alembic upgrade head alembic downgrade -1
C# / .NET EF Core dotnet ef migrations add <Name> dotnet ef database update dotnet ef database update <Prev>

Add the apply/rollback commands as scripts ("migrate", "migrate:rollback") if the scaffold did not.


Every migration file MUST contain real code

  • A complete up() (or upgrade()): CREATE TABLE with all columns and types the handlers use.
  • A complete down() (or downgrade()): reverses the up() (DROP TABLE, etc.).
  • After writing, list the directory and confirm each file is > 0 bytes. An empty migration file does not satisfy Step 1.

Constraints to include (Step 1 requires these)

Constraint When
UNIQUE Business-unique fields (email, slug, external id)
FOREIGN KEY … ON DELETE Every relationship; choose CASCADE / SET NULL deliberately
CHECK Enum-like columns (status, role)
INDEX Columns used in WHERE / JOIN / ORDER BY
NOT NULL + sensible defaults Required columns; timestamps default to now()

Derive the schema from real usage

Read the handler data-access code (and the entity types) before writing columns — the table must match what the code actually reads and writes. Cross-reference every table name against the collection/table names the handlers use (a collectionToTable map if one exists). A mismatch here is the #1 cause of relation "X" does not exist at smoke-test time.

Apply, then prove

  1. Start the local database / emulator if the artifact documents one.
  2. Run the apply command. Expect zero errors.
  3. Confirm the tables now exist (the migration tool's status command, or a \dt against the local DB).

The proof that migrations are correct is Step 2's smoke test passing — handlers querying these tables must not 500.