diff --git a/atlasexec/atlas_models.go b/atlasexec/atlas_models.go index 2af22c7..bbaac14 100644 --- a/atlasexec/atlas_models.go +++ b/atlasexec/atlas_models.go @@ -25,8 +25,8 @@ type ( Applied []string // SQL statements applied with success Checks []*FileChecks // Assertion checks Error *struct { - SQL string // SQL statement that failed. - Error string // Error returned by the database. + Stmt string // SQL statement that failed. + Text string // Error returned by the database. } } // RevertedFile is part of a MigrateDown containing information about a reverted file in a downgrade attempt. @@ -38,8 +38,8 @@ type ( Applied []string // SQL statements applied with success Scope string // Scope of the revert. e.g., statement, versions, etc. Error *struct { - SQL string // SQL statement that failed. - Error string // Error returned by the database. + Stmt string // SQL statement that failed. + Text string // Error returned by the database. } } // MigrateApply contains a summary of a migration applying attempt on a database. diff --git a/atlasexec/atlas_test.go b/atlasexec/atlas_test.go index 58156c5..0f3c508 100644 --- a/atlasexec/atlas_test.go +++ b/atlasexec/atlas_test.go @@ -198,6 +198,14 @@ func TestBrokenApply(t *testing.T) { report, ok := err.(*atlasexec.MigrateApplyError) require.True(t, ok) require.Equal(t, "20231029112426", report.Result[0].Target) + require.Equal(t, "sql/migrate: executing statement \"broken;\" from version \"20231029112426\": near \"broken\": syntax error", report.Error()) + require.Len(t, report.Result[0].Applied, 1) + require.Equal(t, &struct { + Stmt, Text string + }{ + Stmt: "broken;", + Text: "near \"broken\": syntax error", + }, report.Result[0].Applied[0].Error) } func TestMigrateLint(t *testing.T) {