Documentation
¶
Overview ¶
Package a11_destructive_migration enforces that .up.sql schema migrations do not execute destructive DDL operations that break zero-downtime rolling deployments.
Package a11_destructive_migration provides validation for contract-phase annotations and evidence.
Package a11_destructive_migration inspects PostgreSQL AST statements in migrations for destructive DDL.
Package a11_destructive_migration provides a standalone runner to audit migration directories directly.
Index ¶
- Constants
- Variables
- func CheckMigration(filename, content string, dm *directives.DirectiveMap) []migration.Issue
- func IsContractTagged(filename, content string, line int, dm *directives.DirectiveMap) bool
- func ScanMigrationDir(dir string) ([]migration.Issue, error)
- type ContractValidationResult
- type MigrationPhaseMetadata
Constants ¶
const RuleCode = "ARGUS-A11"
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "a11", Doc: "Forbids destructive DDL operations (DROP COLUMN, DROP TABLE, TRUNCATE, RENAME, ALTER TYPE) in .up.sql migrations", Run: run, Requires: []*analysis.Analyzer{ directives.Analyzer, config.Analyzer, }, }
Analyzer defines the analysis.Analyzer for rule ARGUS-A11.
Functions ¶
func CheckMigration ¶
func CheckMigration(filename, content string, dm *directives.DirectiveMap) []migration.Issue
CheckMigration inspects a .up.sql migration for destructive DDL operations.
func IsContractTagged ¶
func IsContractTagged(filename, content string, line int, dm *directives.DirectiveMap) bool
IsContractTagged provides compatibility check for contract evidence or directive suppression.
Types ¶
type ContractValidationResult ¶ added in v1.2.0
type ContractValidationResult struct {
IsValid bool
Reason string
Metadata MigrationPhaseMetadata
}
ContractValidationResult reports whether contract evidence is valid or explains why it failed.
func ValidateContractEvidence ¶ added in v1.2.0
func ValidateContractEvidence(meta *MigrationPhaseMetadata) ContractValidationResult
ValidateContractEvidence verifies that contract metadata represents authoritative contract evidence.
type MigrationPhaseMetadata ¶ added in v1.2.0
type MigrationPhaseMetadata struct {
Phase string // "contract", "expand", "migrate"
Release string // e.g. "v2.0.0", "release_v2"
Issue string // e.g. "PROJ-1234", "#456"
ApprovedBy string // e.g. "alice", "dba-team"
Reason string // descriptive reason (minimum 2 words)
Line int // line where metadata was declared
Raw string // raw comment string
}
MigrationPhaseMetadata captures phase declaration and tracking evidence for a migration.
func ExtractMigrationPhaseMetadata ¶ added in v1.2.0
func ExtractMigrationPhaseMetadata(filename, content string, stmtLine int) *MigrationPhaseMetadata
ExtractMigrationPhaseMetadata extracts contract phase metadata from preceding comments, file header, or path.