cli: add support for skipping execution while generating migrations through the migrate REST API (#4475)

This commit is contained in:
Aravind Shankar 2020-06-02 10:41:47 +05:30 committed by GitHub
parent f14900e7da
commit 16d01bc908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 23 deletions

View File

@ -82,6 +82,7 @@ Read more about the session argument for computed fields in the [docs](https://h
- console: fix visiting view modify page overwriting raw sql content (fix #4798) (#4810)
- console: add help button and move about page to settings (#4848)
- cli: list all available commands in root command help (fix #4623) (#4628)
- cli: add support for skipping execution while generating migrations through the migrate REST API
- docs: add section on actions vs. remote schemas to actions documentation (#4284)
- docs: fix wrong info about excluding scheme in CORS config (#4685)
- docs: add single object mutations docs (close #4622) (#4625)

View File

@ -115,17 +115,18 @@ func (o *ConsoleOptions) Run() error {
adminSecretHeader := cli.GetAdminSecretHeaderName(o.EC.Version)
consoleRouter, err := console.BuildConsoleRouter(templateProvider, consoleTemplateVersion, o.StaticDir, gin.H{
"apiHost": "http://" + o.Address,
"apiPort": o.APIPort,
"cliVersion": o.EC.Version.GetCLIVersion(),
"serverVersion": o.EC.Version.GetServerVersion(),
"dataApiUrl": o.EC.Config.ServerConfig.ParsedEndpoint.String(),
"dataApiVersion": "",
"hasAccessKey": adminSecretHeader == cli.XHasuraAccessKey,
"adminSecret": o.EC.Config.ServerConfig.AdminSecret,
"assetsVersion": consoleAssetsVersion,
"enableTelemetry": o.EC.GlobalConfig.EnableTelemetry,
"cliUUID": o.EC.GlobalConfig.UUID,
"apiHost": "http://" + o.Address,
"apiPort": o.APIPort,
"cliVersion": o.EC.Version.GetCLIVersion(),
"serverVersion": o.EC.Version.GetServerVersion(),
"dataApiUrl": o.EC.Config.ServerConfig.ParsedEndpoint.String(),
"dataApiVersion": "",
"hasAccessKey": adminSecretHeader == cli.XHasuraAccessKey,
"adminSecret": o.EC.Config.ServerConfig.AdminSecret,
"assetsVersion": consoleAssetsVersion,
"enableTelemetry": o.EC.GlobalConfig.EnableTelemetry,
"cliUUID": o.EC.GlobalConfig.UUID,
"migrateSkipExecution": true,
})
if err != nil {
return errors.Wrap(err, "error serving console")

View File

@ -25,7 +25,7 @@ require (
github.com/jinzhu/gorm v1.9.11 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/manifoldco/promptui v0.6.0
github.com/markbates/pkger v0.15.0
github.com/markbates/pkger v0.15.1
github.com/mattn/go-colorable v0.1.4
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/microcosm-cc/bluemonday v1.0.2 // indirect

View File

@ -209,8 +209,8 @@ github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzR
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/manifoldco/promptui v0.6.0 h1:GuXmIdl5lhlamnWf3NbsKWYlaWyHABeStbD1LLsQMuA=
github.com/manifoldco/promptui v0.6.0/go.mod h1:o9/C5VV8IPXxjxpl9au84MtQGIi5dwn7eldAgEdePPs=
github.com/markbates/pkger v0.15.0 h1:rSXoKLBWBgYG7j/h6Be7kggju23ie1Gx3/va9xl5aUw=
github.com/markbates/pkger v0.15.0/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/markbates/pkger v0.15.1 h1:3MPelV53RnGSW07izx5xGxl4e/sdRD6zqseIk0rMASY=
github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=

View File

@ -31,9 +31,10 @@ type Response struct {
}
type Request struct {
Name string `json:"name"`
Up []requestType `json:"up"`
Down []requestType `json:"down"`
Name string `json:"name"`
Up []requestType `json:"up"`
Down []requestType `json:"down"`
SkipExecution bool `json:"skip_execution"`
}
type requestType struct {
@ -200,7 +201,7 @@ func MigrateAPI(c *gin.Context) {
return
}
if err = t.QueryWithVersion(uint64(timestamp), ioutil.NopCloser(bytes.NewReader(upByt))); err != nil {
if err = t.QueryWithVersion(uint64(timestamp), ioutil.NopCloser(bytes.NewReader(upByt)), request.SkipExecution); err != nil {
if strings.HasPrefix(err.Error(), DataAPIError) {
c.JSON(http.StatusBadRequest, &Response{Code: "data_api_error", Message: strings.TrimPrefix(err.Error(), DataAPIError)})
return

View File

@ -542,7 +542,7 @@ func (m *Migrate) Migrate(version uint64, direction string) error {
return m.unlockErr(m.runMigrations(ret))
}
func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser) error {
func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser, skipExecution bool) error {
mode, err := m.databaseDrv.GetSetting("migration_mode")
if err != nil {
return err
@ -556,9 +556,11 @@ func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser) error {
return err
}
if err := m.databaseDrv.Run(data, "meta", ""); err != nil {
m.databaseDrv.ResetQuery()
return m.unlockErr(err)
if !skipExecution {
if err := m.databaseDrv.Run(data, "meta", ""); err != nil {
m.databaseDrv.ResetQuery()
return m.unlockErr(err)
}
}
if version != 0 {

View File

@ -19,6 +19,7 @@
enableTelemetry: {{.enableTelemetry}},
assetsPath: "https://graphql-engine-cdn.hasura.io/console/assets",
serverVersion: "{{.serverVersion}}",
migrateSkipExecution: {{.migrateSkipExecution}}
};
</script>
</head>

File diff suppressed because one or more lines are too long