cli: apply the migration after creating for flag --from-server

Issue: https://github.com/hasura/graphql-engine/issues/7510

Problem:

- To mark the migration applied after creating the migration from the server with skip-execution flag

Solution:

After creating migration apply it with skip-execution true

https://github.com/hasura/graphql-engine-mono/pull/2333

Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 72eca352b76afe3a19d2198169b31284e38af07a
This commit is contained in:
Kali Vara Purushotham Santhati 2021-09-22 17:17:37 +05:30 committed by hasura-bot
parent 112d206fa6
commit 24d9bbcd93
2 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,7 @@
- console: add GraphQL customisation under Remote schema edit tab
- console: fix cross-schema array relationship suggestions
- cli: add support for `network` metadata object
- cli: `migrate create --from-server` creates the migration and marks it as applied on the server
## v2.0.9

View File

@ -223,6 +223,19 @@ func (o *migrateCreateOptions) run() (version int64, err error) {
if err != nil {
return 0, errors.Wrap(err, "error creating migration files")
}
if o.fromServer {
opts := &MigrateApplyOptions{
EC: o.EC,
SkipExecution: true,
VersionMigration: fmt.Sprintf("%d", timestamp),
Source: o.Source,
}
err := opts.Run()
if err != nil {
o.EC.Logger.Warnf("cannot mark created migration %d as applied: %v", timestamp, err)
o.EC.Logger.Warnf("manually mark it as applied using command: hasura migrate apply --skip-execution --version %d", timestamp)
}
}
return timestamp, nil
}