mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
cli: add support for skipping execution while generating migrations through the migrate REST API (#4475)
This commit is contained in:
parent
f14900e7da
commit
16d01bc908
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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=
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
Loading…
Reference in New Issue
Block a user