Coding agents can automate routine database migration tasks, such as generating DDL or updating tests. However, migrations carry significant operational risks, as an unsuccessful ALTER TABLE command can block database queries, exhaust connection pools, and cause service outages. These risks are amplified when agents generate schema changes without awareness of production-specific constraints.

The author proposes treating agent-generated migrations as privileged artifacts, similar to Terraform or Kubernetes configurations. A dedicated CI firewall should enforce strict rules, such as identifying dangerous operations like RunSQL, RemoveField, or standard index creation on large tables. Automated checks should analyze generated SQL rather than just Python code to assess real-world impact.

Effective migration policies should include static analysis of migration operations and the use of PostgreSQL-specific features like CREATE INDEX CONCURRENTLY or AddConstraintNotValid. These tools help maintain application compatibility during rolling deployments. The author suggests implementing a CI pipeline that generates risk reports and requires manual approval for high-risk changes.

The proposed CI workflow includes running migration checks, generating SQL artifacts, and validating them against a policy engine. This approach separates the agent's role in proposing changes from the objective verification provided by parsers, database metrics, and human review. This structure allows agents to operate efficiently within defined safety boundaries.