Files
devops-engineer 11f15aa86e
schema-drift-check / drift-check (push) Failing after 15s
chore: bootstrap Atlas schema-SSOT Phase 1 (RFC#549)
Phase 1 scope: molecule-core-postgres-1 docker dev DB only.
Phase 2 (Neon staging) and Phase 3 (Neon prod) deferred per CTO
2026-05-19 GO option C on the schema-SSOT memory.

Contents:
- atlas.hcl: 3 envs (mc-postgres wired, neon-staging/neon-prod stubbed)
- mc/schema/schema.hcl: declarative HCL captured from live mc-postgres
  (30 tables, 1878 lines)
- mc/migrations/20260519191337_baseline.sql: initial migration generated
  from the declarative schema
- mc/migrations/atlas.sum: integrity hash
- .gitea/workflows/ci-drift-check.yml: PR gate (validate + destructive-op
  down.sql requirement). Uses OSS `atlas migrate validate` since
  `migrate lint` was paywalled in v0.38+ — see open question below.
- Makefile + README quickstart targets

Open questions raised during PoC:
1. Atlas Pro lint vs OSS validate — accept OSS floor, or license Pro for
   destructive-change/data-loss analyzers? Current workflow uses a
   grep-based destructive-op check as a stopgap.

This commit is the PoC for RFC#549 Phase 1. No live DB was mutated;
Atlas plans against an ephemeral docker dev DB. The existing
molecule-core/migrations/ and molecule-controlplane/migrations/
directories remain authoritative for their products until cut over.
2026-05-19 12:14:38 -07:00

43 lines
1.6 KiB
Makefile

SHELL := /bin/bash
# Default env for local development; override on the CLI:
# make schema-diff ENV=neon-staging
ENV ?= mc-postgres
# Local docker-compose Postgres (RFC#549 Phase 1 target).
# Override MC_POSTGRES_URL if your local DB is on a different host/port.
export MC_POSTGRES_URL ?= postgres://dev:dev@localhost:5432/molecule?sslmode=disable
.PHONY: schema-inspect schema-diff schema-plan schema-apply migrate-hash migrate-validate help
help:
@echo "Targets:"
@echo " make schema-inspect ENV=$(ENV) - dump live DB schema to stdout as HCL"
@echo " make schema-diff ENV=$(ENV) - show pending changes (live -> schema.hcl)"
@echo " make schema-plan ENV=$(ENV) NAME=<n> - generate a versioned migration"
@echo " make schema-apply ENV=$(ENV) - apply migrations to live DB (NO --auto-approve)"
@echo " make migrate-hash - refresh mc/migrations/atlas.sum"
@echo " make migrate-validate - validate integrity + SQL semantics (OSS)"
schema-inspect:
atlas schema inspect --env $(ENV)
schema-diff:
atlas schema diff \
--from "$$(atlas schema inspect --env $(ENV) --format '{{ sql . }}' | sed 's|^|-- |')" \
--to file://mc/schema/schema.hcl \
--dev-url 'docker://postgres/16/dev' || true
schema-plan:
@test -n "$(NAME)" || (echo "ERROR: NAME=<migration_name> is required"; exit 1)
atlas migrate diff $(NAME) --env $(ENV)
schema-apply:
atlas migrate apply --env $(ENV)
migrate-hash:
atlas migrate hash --dir file://mc/migrations
migrate-validate:
atlas migrate validate --dir file://mc/migrations --dev-url 'docker://postgres/16/dev'