mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
doc/md: document usage of atlas supported migration tools (#2467)
* doc/md: document usage of atlas supported migration tools * dialect/sql/schema: fix tests
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"ariga.io/atlas/sql/migrate"
|
||||
"ariga.io/atlas/sql/schema"
|
||||
"ariga.io/atlas/sql/sqltool"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
entsql "entgo.io/ent/dialect/sql"
|
||||
@@ -315,7 +316,7 @@ func (m *Migrate) setupAtlas() error {
|
||||
m.atlas.diff = append(m.atlas.diff, withoutForeignKeys)
|
||||
}
|
||||
if m.atlas.dir != nil && m.atlas.fmt == nil {
|
||||
m.atlas.fmt = migrate.DefaultFormatter
|
||||
m.atlas.fmt = sqltool.GolangMigrateFormatter
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -81,9 +80,9 @@ func TestMigrate_Diff(t *testing.T) {
|
||||
m, err := NewMigrate(db, WithDir(d))
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, m.Diff(context.Background(), &Table{Name: "users"}))
|
||||
v := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
requireFileEqual(t, filepath.Join(p, v+"_changes.up.sql"), "CREATE TABLE `users` (, PRIMARY KEY ());\n")
|
||||
requireFileEqual(t, filepath.Join(p, v+"_changes.down.sql"), "DROP TABLE `users`;\n")
|
||||
v := time.Now().Format("20060102150405")
|
||||
requireFileEqual(t, filepath.Join(p, v+"_changes.up.sql"), "-- create \"users\" table\nCREATE TABLE `users` (, PRIMARY KEY ());\n")
|
||||
requireFileEqual(t, filepath.Join(p, v+"_changes.down.sql"), "-- reverse: create \"users\" table\nDROP TABLE `users`;\n")
|
||||
require.NoFileExists(t, filepath.Join(p, "atlas.sum"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user