diff --git a/.circleci/config.yml b/.circleci/config.yml index b1ec88d281f..c65a63357de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -365,14 +365,14 @@ jobs: - checkout - restore_cache: key: - cli-ext-npm-cache-v1-{{ checksum "cli-ext/package.json" }}-{{ checksum "cli-ext/package-lock.json" }} + cli-ext-npm-cache-v2-{{ checksum "cli-ext/package.json" }}-{{ checksum "cli-ext/package-lock.json" }} - run: name: install dependencies working_directory: cli-ext command: make ci-deps - save_cache: key: - cli-ext-npm-cache-v1-{{ checksum "cli-ext/package.json" }}-{{ checksum "cli-ext/package-lock.json" }} + cli-ext-npm-cache-v2-{{ checksum "cli-ext/package.json" }}-{{ checksum "cli-ext/package-lock.json" }} paths: - cli-ext/node_modules - ~/.npm diff --git a/cli/commands/migrate_create.go b/cli/commands/migrate_create.go index c1c567325b9..6f02a436d44 100644 --- a/cli/commands/migrate_create.go +++ b/cli/commands/migrate_create.go @@ -89,7 +89,17 @@ func (o *migrateCreateOptions) run() (version int64, err error) { if o.fromServer { o.sqlServer = true - o.metaDataServer = true + if o.EC.Config.Version == cli.V1 { + o.metaDataServer = true + } + } + + if o.flags.Changed("metadata-from-file") && o.EC.Config.Version != cli.V1 { + return 0, errors.New("metadata-from-file flag can be set only with config version 1") + } + + if o.flags.Changed("metadata-from-server") && o.EC.Config.Version != cli.V1 { + return 0, errors.New("metadata-from-server flag can be set only with config version 1") } if o.flags.Changed("metadata-from-file") && o.sqlServer { @@ -131,7 +141,7 @@ func (o *migrateCreateOptions) run() (version int64, err error) { } // Create metadata migrations only if config version is V1 - if o.metaDataServer && ec.Config.Version == cli.V1 { + if o.metaDataServer { // To create metadata.yaml, set metadata plugin tmpDirName, err := ioutil.TempDir("", "*") if err != nil { @@ -159,12 +169,18 @@ func (o *migrateCreateOptions) run() (version int64, err error) { } } - if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer { + if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version == cli.V1 { // Set empty data for [up|down].yaml createOptions.MetaUp = []byte(`[]`) createOptions.MetaDown = []byte(`[]`) } + if !o.flags.Changed("sql-from-file") && !o.flags.Changed("metadata-from-file") && !o.metaDataServer && !o.sqlServer && o.EC.Config.Version != cli.V1 { + // Set empty data for [up|down].sql + createOptions.SQLUp = []byte(``) + createOptions.SQLDown = []byte(``) + } + defer func() { if err != nil { createOptions.Delete() diff --git a/cli/migrate/migrate.go b/cli/migrate/migrate.go index 6d0e9da1416..a1f43e49584 100644 --- a/cli/migrate/migrate.go +++ b/cli/migrate/migrate.go @@ -766,7 +766,7 @@ func (m *Migrate) squashDown(version uint64, ret chan<- interface{}) { } prev, err := m.sourceDrv.Prev(from) - if err != nil { + if os.IsNotExist(err) { migr, err := m.metanewMigration(from, -1) if err != nil { ret <- err @@ -782,6 +782,10 @@ func (m *Migrate) squashDown(version uint64, ret chan<- interface{}) { } ret <- migr go migr.Buffer() + return + } else if err != nil { + ret <- err + return } migr, err := m.metanewMigration(from, int64(prev))