mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
This commit is contained in:
parent
d0effffbf6
commit
56dbc59822
@ -79,8 +79,9 @@ func (f *File) Open(url string, logger *log.Logger) (source.Driver, error) {
|
||||
continue // ignore files that we can't parse
|
||||
}
|
||||
|
||||
if !nf.migrations.Append(m) {
|
||||
return nil, fmt.Errorf("unable to parse file %v", fi.Name())
|
||||
err = nf.migrations.Append(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
@ -47,9 +48,9 @@ func NewMigrations() *Migrations {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Migrations) Append(m *Migration) (ok bool) {
|
||||
func (i *Migrations) Append(m *Migration) (err error) {
|
||||
if m == nil {
|
||||
return false
|
||||
return fmt.Errorf("migration cannot be nill")
|
||||
}
|
||||
|
||||
if i.migrations[m.Version] == nil {
|
||||
@ -57,13 +58,13 @@ func (i *Migrations) Append(m *Migration) (ok bool) {
|
||||
}
|
||||
|
||||
// reject duplicate versions
|
||||
if _, dup := i.migrations[m.Version][m.Direction]; dup {
|
||||
return false
|
||||
if migration, dup := i.migrations[m.Version][m.Direction]; dup {
|
||||
return fmt.Errorf("found duplicate migrations for version %d\n- %s\n- %s", m.Version, m.Raw, migration.Raw)
|
||||
}
|
||||
|
||||
i.migrations[m.Version][m.Direction] = m
|
||||
i.buildIndex()
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Migrations) buildIndex() {
|
||||
|
Loading…
Reference in New Issue
Block a user