Detects breaking changes in DDL statements
go install github.com/ebi-yade/breaql/cmd/breaql@latest
go get github.com/ebi-yade/breaql
You can pass the DDL statements via stdin or as a file.
echo '
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100));
ALTER TABLE users DROP COLUMN age;
DROP TABLE users;
DROP DATABASE foo;
' | go run breaql --driver mysql
And then you will see the output like this:
-- Detected destructive changes:
-- Table: users
ALTER TABLE users DROP COLUMN age;
DROP TABLE users;
-- Database: foo
DROP DATABASE foo;
package main
import (
"fmt"
"log"
"github.com/ebi-yade/breaql"
)
func main() {
ddl := `
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100));
ALTER TABLE users DROP COLUMN age; -- breaking!
`
changes, err := breaql.RunMySQL(ddl)
if err != nil {
log.Fatal(err)
}
if changes.Exist() {
fmt.Println("No breaking changes detected")
} else {
fmt.Println("-- Detected destructive changes:")
fmt.Printf(changes.FormatSQL())
}
}