feat: use the new atlas engine for migrations

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Mark Sagi-Kazar 2022-03-07 10:18:32 +01:00
parent 20b03b3f6d
commit 0c3c577b52
No known key found for this signature in database
GPG key ID: 31AB0439F4C5C90E
3 changed files with 6 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import (
"time" "time"
entSQL "entgo.io/ent/dialect/sql" entSQL "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"
"github.com/go-sql-driver/mysql" "github.com/go-sql-driver/mysql"
// Register postgres driver. // Register postgres driver.
@ -56,7 +57,7 @@ func (m *MySQL) Open(logger log.Logger) (storage.Storage, error) {
client.WithTxIsolationLevel(sql.LevelSerializable), client.WithTxIsolationLevel(sql.LevelSerializable),
) )
if err := databaseClient.Schema().Create(context.TODO()); err != nil { if err := databaseClient.Schema().Create(context.TODO(), schema.WithAtlas(true)); err != nil {
return nil, err return nil, err
} }

View file

@ -12,6 +12,7 @@ import (
"time" "time"
entSQL "entgo.io/ent/dialect/sql" entSQL "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"
// Register postgres driver. // Register postgres driver.
_ "github.com/lib/pq" _ "github.com/lib/pq"
@ -56,7 +57,7 @@ func (p *Postgres) Open(logger log.Logger) (storage.Storage, error) {
client.WithTxIsolationLevel(sql.LevelSerializable), client.WithTxIsolationLevel(sql.LevelSerializable),
) )
if err := databaseClient.Schema().Create(context.TODO()); err != nil { if err := databaseClient.Schema().Create(context.TODO(), schema.WithAtlas(true)); err != nil {
return nil, err return nil, err
} }

View file

@ -6,6 +6,7 @@ import (
"strings" "strings"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/schema"
// Register sqlite driver. // Register sqlite driver.
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
@ -43,7 +44,7 @@ func (s *SQLite3) Open(logger log.Logger) (storage.Storage, error) {
client.WithHasher(sha256.New), client.WithHasher(sha256.New),
) )
if err := databaseClient.Schema().Create(context.TODO()); err != nil { if err := databaseClient.Schema().Create(context.TODO(), schema.WithAtlas(true)); err != nil {
return nil, err return nil, err
} }