Skip to content

Commit

Permalink
feat: refuse to start when version check does not pass
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jan 28, 2022
1 parent 395a8a3 commit ff8d767
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dialect/mysqldialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package mysqldialect
import (
"database/sql"
"encoding/hex"
"fmt"
"log"
"strings"
"time"
"unicode/utf8"

"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"
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions dialect/mysqldialect/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package mysqldialect

// Version is the current release version.
func Version() string {
return "1.0.21"
}
9 changes: 9 additions & 0 deletions dialect/pgdialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions dialect/pgdialect/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package pgdialect

// Version is the current release version.
func Version() string {
return "1.0.21"
}
9 changes: 9 additions & 0 deletions dialect/sqlitedialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions dialect/sqlitedialect/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package sqlitedialect

// Version is the current release version.
func Version() string {
return "1.0.21"
}
3 changes: 3 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff8d767

Please sign in to comment.