diff --git a/dialect/mysqldialect/dialect.go b/dialect/mysqldialect/dialect.go index 25421e2dd..f82715bbc 100644 --- a/dialect/mysqldialect/dialect.go +++ b/dialect/mysqldialect/dialect.go @@ -3,6 +3,7 @@ package mysqldialect import ( "database/sql" "encoding/hex" + "fmt" "log" "strings" "time" @@ -10,6 +11,7 @@ import ( "golang.org/x/mod/semver" + "github.com/uptrace/bun" "github.com/uptrace/bun/dialect" "github.com/uptrace/bun/dialect/feature" "github.com/uptrace/bun/dialect/sqltype" @@ -18,6 +20,13 @@ import ( const datetimeType = "DATETIME" +func init() { + if Version() != bun.Version() { + panic(fmt.Errorf("mysqldialect and Bun must have the same version: v%s != v%s", + Version(), bun.Version())) + } +} + type Dialect struct { schema.BaseDialect diff --git a/dialect/mysqldialect/version.go b/dialect/mysqldialect/version.go new file mode 100644 index 000000000..f1e1e05aa --- /dev/null +++ b/dialect/mysqldialect/version.go @@ -0,0 +1,6 @@ +package mysqldialect + +// Version is the current release version. +func Version() string { + return "1.0.21" +} diff --git a/dialect/pgdialect/dialect.go b/dialect/pgdialect/dialect.go index 0d38d37fe..9ff781459 100644 --- a/dialect/pgdialect/dialect.go +++ b/dialect/pgdialect/dialect.go @@ -2,9 +2,11 @@ package pgdialect import ( "database/sql" + "fmt" "strconv" "strings" + "github.com/uptrace/bun" "github.com/uptrace/bun/dialect" "github.com/uptrace/bun/dialect/feature" "github.com/uptrace/bun/dialect/sqltype" @@ -13,6 +15,13 @@ import ( var pgDialect = New() +func init() { + if Version() != bun.Version() { + panic(fmt.Errorf("pgdialect and Bun must have the same version: v%s != v%s", + Version(), bun.Version())) + } +} + type Dialect struct { schema.BaseDialect diff --git a/dialect/pgdialect/version.go b/dialect/pgdialect/version.go new file mode 100644 index 000000000..b2bd1d9f1 --- /dev/null +++ b/dialect/pgdialect/version.go @@ -0,0 +1,6 @@ +package pgdialect + +// Version is the current release version. +func Version() string { + return "1.0.21" +} diff --git a/dialect/sqlitedialect/dialect.go b/dialect/sqlitedialect/dialect.go index e02a946d0..989686bc3 100644 --- a/dialect/sqlitedialect/dialect.go +++ b/dialect/sqlitedialect/dialect.go @@ -3,13 +3,22 @@ package sqlitedialect import ( "database/sql" "encoding/hex" + "fmt" + "github.com/uptrace/bun" "github.com/uptrace/bun/dialect" "github.com/uptrace/bun/dialect/feature" "github.com/uptrace/bun/dialect/sqltype" "github.com/uptrace/bun/schema" ) +func init() { + if Version() != bun.Version() { + panic(fmt.Errorf("sqlitedialect and Bun must have the same version: v%s != v%s", + Version(), bun.Version())) + } +} + type Dialect struct { schema.BaseDialect diff --git a/dialect/sqlitedialect/version.go b/dialect/sqlitedialect/version.go new file mode 100644 index 000000000..ed00f0706 --- /dev/null +++ b/dialect/sqlitedialect/version.go @@ -0,0 +1,6 @@ +package sqlitedialect + +// Version is the current release version. +func Version() string { + return "1.0.21" +} diff --git a/scripts/release.sh b/scripts/release.sh index ccbd93bbd..58192e215 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -58,6 +58,9 @@ do done sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./version.go +sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./dialect/mysqldialect/version.go +sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./dialect/pgdialect/version.go +sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./dialect/sqlitedialect/version.go sed --in-place "s/\(\"version\": \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./package.json conventional-changelog -p angular -i CHANGELOG.md -s