Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 26, 2024
1 parent 85539a4 commit 3fee002
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 40 deletions.
5 changes: 3 additions & 2 deletions cmd/cli/handler_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ package cli
import (
"bytes"
"fmt"
"github.com/ory/x/popx"
"github.com/ory/x/servicelocatorx"
"io"
"io/fs"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/ory/x/popx"
"github.com/ory/x/servicelocatorx"

"github.com/pkg/errors"

"github.com/ory/x/configx"
Expand Down
11 changes: 6 additions & 5 deletions cmd/migrate_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ory/hydra/v2/cmd/cli"
)

func NewMigrateSqlCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
func NewMigrateSQLCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := &cobra.Command{
Use: "sql <database-url>",
Deprecated: "Please use `migrate sql up` instead.",
Expand All @@ -26,18 +26,19 @@ This decreases risk of failure and decreases time required.
You can read in the database URL using the -e flag, for example:
export DSN=...
hydra migrate sql -e
hydra migrate sql up -e
### WARNING ###
Before running this command on an existing database, create a back up!`,
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLUp,
}

cmd.Flags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")
cmd.Flags().BoolP("yes", "y", false, "If set all confirmation requests are accepted without user interaction.")
cmd.PersistentFlags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")

cmd.AddCommand(NewMigrateSQLDownCmd(slOpts, dOpts, cOpts))
cmd.AddCommand(NewMigrateSQLUpCmd(slOpts, dOpts, cOpts))

cmd.AddCommand(NewMigrateSqlDownCmd(slOpts, dOpts, cOpts))
cmd.AddCommand(NewMigrateSqlUpCmd(slOpts, dOpts, cOpts))
return cmd
}
15 changes: 5 additions & 10 deletions cmd/migrate_sql_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ package cmd
import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

"github.com/ory/hydra/v2/driver"
"github.com/ory/x/configx"
"github.com/ory/x/servicelocatorx"

"github.com/ory/hydra/v2/cmd/cli"
)

func NewMigrateSqlDownCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := &cobra.Command{
func NewMigrateSQLDownCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
return popx.RegisterMigrateSQLDownFlags(&cobra.Command{
Use: "down <database-url>",
Short: "Roll back SQL migrations",
Args: cobra.RangeArgs(0, 1),
Expand Down Expand Up @@ -48,12 +50,5 @@ roll back. For example, to roll back the most recent migration, you can run:
DSN=... hydra migrate sql down -e --steps 1`,
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLDown,
}

cmd.Flags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")
cmd.Flags().BoolP("yes", "y", false, "If set all confirmation requests are accepted without user interaction.")
cmd.Flags().Int("steps", 0, "The number of migrations to roll back.")
cmd.Flags().StringSlice("version", []string{}, "One or more migration versions.")

return cmd
})
}
25 changes: 25 additions & 0 deletions cmd/migrate_sql_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright © 2022 Ory Corp
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

"github.com/ory/hydra/v2/driver"
"github.com/ory/x/configx"
"github.com/ory/x/servicelocatorx"

"github.com/ory/hydra/v2/cmd/cli"
)

func NewMigrateSQLStatusCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
return popx.RegisterMigrateStatusFlags(&cobra.Command{
Use: "status",
Deprecated: "Please use `migrate sql status` instead.",
Short: "Get the current migration status",
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateStatus,
})
}
13 changes: 5 additions & 8 deletions cmd/migrate_sql_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ package cmd
import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

"github.com/ory/hydra/v2/driver"
"github.com/ory/x/configx"
"github.com/ory/x/servicelocatorx"

"github.com/ory/hydra/v2/cmd/cli"
)

func NewMigrateSqlUpCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := &cobra.Command{
func NewMigrateSQLUpCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
return popx.RegisterMigrateSQLUpFlags(&cobra.Command{
Use: "up <database-url>",
Args: cobra.RangeArgs(0, 1),
Short: "Create and upgrade the Ory Hydra SQL schema",
Expand All @@ -32,10 +34,5 @@ flag:
DSN=... hydra migrate sql up -e`,
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLUp,
}

cmd.Flags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")
cmd.Flags().BoolP("yes", "y", false, "If set all confirmation requests are accepted without user interaction.")

return cmd
})
}
19 changes: 8 additions & 11 deletions cmd/migrate_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package cmd

import (
"github.com/ory/x/cmdx"
"github.com/ory/x/configx"
"github.com/ory/x/popx"
"github.com/ory/x/servicelocatorx"

"github.com/spf13/cobra"
Expand All @@ -15,15 +15,12 @@ import (
)

func NewMigrateStatusCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "Get the current migration status",
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateStatus,
}

cmdx.RegisterFormatFlags(cmd.PersistentFlags())
cmd.Flags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")
cmd.Flags().Bool("block", false, "Block until all migrations have been applied")

cmd := popx.RegisterMigrateStatusFlags(&cobra.Command{
Use: "status",
Deprecated: "Please use `migrate sql status` instead.",
Short: "Get the current migration status",
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateStatus,
})
cmd.PersistentFlags().BoolP("read-from-env", "e", false, "If set, reads the database connection string from the environment variable DSN or config file key dsn.")
return cmd
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func RegisterCommandRecursive(parent *cobra.Command, slOpts []servicelocatorx.Op

migrateCmd := NewMigrateCmd()
migrateCmd.AddCommand(NewMigrateGenCmd())
migrateCmd.AddCommand(NewMigrateSqlCmd(slOpts, dOpts, cOpts))
migrateCmd.AddCommand(NewMigrateSQLCmd(slOpts, dOpts, cOpts))
migrateCmd.AddCommand(NewMigrateStatusCmd(slOpts, dOpts, cOpts))

serveCmd := NewServeCmd()
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ replace github.com/gobuffalo/pop/v6 => github.com/ory/pop/v6 v6.2.0
// may be breaking for some users.
replace github.com/ory/fosite => github.com/ory/fosite v0.47.1-0.20241101073333-eab241e153a4

replace github.com/ory/x => ../x

require (
github.com/ThalesIgnite/crypto11 v1.2.5
github.com/bradleyjkemp/cupaloy/v2 v2.8.0
Expand Down Expand Up @@ -49,7 +47,7 @@ require (
github.com/ory/hydra-client-go/v2 v2.2.1
github.com/ory/jsonschema/v3 v3.0.8
github.com/ory/kratos-client-go v1.2.1
github.com/ory/x v0.0.668
github.com/ory/x v0.0.671
github.com/pborman/uuid v1.2.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ github.com/ory/kratos-client-go v1.2.1 h1:Q3T/adfAfAkHFcV1LGLnwz4QkY6ghBdX9zde5T
github.com/ory/kratos-client-go v1.2.1/go.mod h1:WiQYlrqW4Atj6Js7oDN5ArbZxo0nTO2u/e1XaDv2yMI=
github.com/ory/pop/v6 v6.2.0 h1:hRFOGAOEHw91kUHQ32k5NHqCkcHrRou/romvrJP1w0E=
github.com/ory/pop/v6 v6.2.0/go.mod h1:okVAYKGtgunD/wbW3NGhZTndJCS+6FqO+cA89rQ4doc=
github.com/ory/x v0.0.671 h1:1kDSqsQVhgRQQJWGQWRNEF9kVp1hhVFJH9VlyRh+rZ4=
github.com/ory/x v0.0.671/go.mod h1:0Av1u/Gh7WXCrEDJJnySAJrDzluaWllOfl5zqf9Dky8=
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
Expand Down

0 comments on commit 3fee002

Please sign in to comment.