Skip to content

Commit

Permalink
sql/mysql: support validating mysql collation/charset
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m committed Jun 16, 2022
1 parent 3a51588 commit dacb0ec
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 46 deletions.
4 changes: 4 additions & 0 deletions internal/integration/testdata/sqlite/cli-atlasci-sanity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ cmp got2.txt expected2.txt

-- migrations/1.sql --
CREATE TABLE users (id int);

CREATE TABLE pets (id int);

-- migrations/2.sql --
DROP TABLE users;

-- migrations/3.sql --
DROP TABLE pets;

-- expected1.txt --
Destructive changes detected in file 3.sql:

Expand Down
6 changes: 4 additions & 2 deletions sql/internal/sqlx/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type (
// If the DiffDriver implements the Normalizer interface, TableDiff normalizes its table
// inputs before starting the diff process.
Normalizer interface {
Normalize(from, to *schema.Table)
Normalize(from, to *schema.Table) error
}
)

Expand Down Expand Up @@ -148,7 +148,9 @@ func (d *Diff) TableDiff(from, to *schema.Table) ([]schema.Change, error) {
}
// Normalizing tables before starting the diff process.
if n, ok := d.DiffDriver.(Normalizer); ok {
n.Normalize(from, to)
if err := n.Normalize(from, to); err != nil {
return nil, err
}
}
var changes []schema.Change
if from.Name != to.Name {
Expand Down
Loading

0 comments on commit dacb0ec

Please sign in to comment.