mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
Merge pull request #4882 from scriptonist/fix-update-scripts-bug
cli: fix upgrade scripts bug
This commit is contained in:
commit
b5ca6ec29f
@ -151,12 +151,13 @@ func newScriptsUpdateConfigV2Cmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
}
|
||||
fileCfg.Migrations.Migrations[version][source.Up] = &source.Migration{}
|
||||
} else {
|
||||
upByt, err := ioutil.ReadFile(upMigration.Raw)
|
||||
filePath := filepath.Join(ec.MigrationDir, upMigration.Raw)
|
||||
upByt, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in reading up.sql")
|
||||
}
|
||||
upByt = append(upByt, sqlUp.Bytes()...)
|
||||
err = ioutil.WriteFile(upMigration.Raw, upByt, os.ModePerm)
|
||||
err = ioutil.WriteFile(filePath, upByt, os.ModePerm)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in writing up.sql")
|
||||
}
|
||||
@ -224,12 +225,13 @@ func newScriptsUpdateConfigV2Cmd(ec *cli.ExecutionContext) *cobra.Command {
|
||||
}
|
||||
fileCfg.Migrations.Migrations[version][source.Down] = &source.Migration{}
|
||||
} else {
|
||||
downByt, err := ioutil.ReadFile(downMigration.Raw)
|
||||
filePath := filepath.Join(ec.MigrationDir, downMigration.Raw)
|
||||
downByt, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in reading down.sql")
|
||||
}
|
||||
downByt = append(sqlDown.Bytes(), downByt...)
|
||||
err = ioutil.WriteFile(downMigration.Raw, downByt, os.ModePerm)
|
||||
err = ioutil.WriteFile(filePath, downByt, os.ModePerm)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in writing down.sql")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user