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 27, 2024
1 parent 3fee002 commit 9cb7782
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 165 deletions.
4 changes: 2 additions & 2 deletions cmd/janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (

func NewJanitorCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := &cobra.Command{
Use: "janitor [<database-url>]",
Use: "janitor [[database_url]]",
Short: "This command cleans up stale database rows.",
Example: `hydra janitor --keep-if-younger 23h --access-lifespan 1h --refresh-lifespan 40h --consent-request-lifespan 10m <database-url>`,
Example: `hydra janitor --keep-if-younger 23h --access-lifespan 1h --refresh-lifespan 40h --consent-request-lifespan 10m [database_url]`,
Long: `This command cleans up stale database rows. This will select records to delete with a limit
and delete records in batch to ensure that no table locking issues arise in big production
databases.
Expand Down
11 changes: 5 additions & 6 deletions cmd/migrate_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
package cmd

import (
"github.com/spf13/cobra"

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

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

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.",
Use: "sql [database_url]",
Deprecated: "Please use `hydra migrate sql up` instead.",
Short: "Perform SQL migrations",
Long: `Run this command on a fresh SQL installation and when you upgrade Hydra to a new minor version. For example,
upgrading Hydra 0.7.0 to 0.8.0 requires running this command.
Expand All @@ -39,6 +37,7 @@ Before running this command on an existing database, create a back up!`,

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

return cmd
}
45 changes: 4 additions & 41 deletions cmd/migrate_sql_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,14 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

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

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

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),
Example: `Revert the most recent migration:
DSN=... hydra migrate sql down -e --steps 1
Review migrations to decide which one to roll back:
DSN=... hydra migrate sql down -e --steps 0
Revert a specific migration:
DSN=... hydra migrate sql down -e --version 20230606112801000001
`,
Long: `Run this command to roll back SQL migrations. This command is useful when you want to revert to a previous version of Ory Hydra.
:::warning
Before running this command on an existing database, create a back up. This command can be destructive as it may drop
indices, columns, or whole tables. Run this command close to the SQL instance (same VPC / same machine).
:::
This command will not execute anything unless you provide a --steps flag with a value greater than 0. Per default, this
command will roll back one migration at a time. You can specify the number of migrations to roll back using the --steps
flag.
Choosing how many migrations to roll back depends on the current state of the database. Please first execute the command
without the --steps flag to review the migrations and decide which one to roll back.
Once you have decided which migration to roll back, you can use the --steps flag to specify the number of migrations to
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,
})
return popx.NewMigrateSQLDownCmd("hydra", cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLDown)
}
16 changes: 4 additions & 12 deletions cmd/migrate_sql_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

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

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

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,
})
return popx.NewMigrateStatusCmd("hydra", cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateStatus)
}
29 changes: 4 additions & 25 deletions cmd/migrate_sql_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,14 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/ory/x/popx"

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

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

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",
Long: `Run this command on a fresh SQL installation and when you upgrade Ory Hydra to a newer version.
:::warning
Before running this command on an existing database, create a back up. This command can be destructive as it may drop
indices, columns, or whole tables. Run this command close to the SQL instance (same VPC / same machine).
:::
It is recommended to review the migrations before running them. You can do this by running the command without the --yes
flag:
DSN=... hydra migrate sql up -e`,
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLUp,
})
return popx.NewMigrateSQLDownCmd("hydra", cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateSQLUp)
}
2 changes: 1 addition & 1 deletion cmd/migrate_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func NewMigrateStatusCmd(slOpts []servicelocatorx.Option, dOpts []driver.OptionsModifier, cOpts []configx.OptionModifier) *cobra.Command {
cmd := popx.RegisterMigrateStatusFlags(&cobra.Command{
Use: "status",
Deprecated: "Please use `migrate sql status` instead.",
Deprecated: "Please use `hydra migrate sql status` instead.",
Short: "Get the current migration status",
RunE: cli.NewHandler(slOpts, dOpts, cOpts).Migration.MigrateStatus,
})
Expand Down
52 changes: 26 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,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.671
github.com/ory/x v0.0.674
github.com/pborman/uuid v1.2.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
Expand All @@ -63,16 +63,16 @@ require (
github.com/toqueteos/webbrowser v1.2.0
github.com/twmb/murmur3 v1.1.8
github.com/urfave/negroni v1.0.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0
go.opentelemetry.io/otel v1.32.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0
go.opentelemetry.io/otel/sdk v1.32.0
go.opentelemetry.io/otel/trace v1.32.0
go.uber.org/automaxprocs v1.5.3
golang.org/x/crypto v0.25.0
golang.org/x/crypto v0.28.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/oauth2 v0.21.0
golang.org/x/sync v0.7.0
golang.org/x/oauth2 v0.23.0
golang.org/x/sync v0.9.0
golang.org/x/tools v0.23.0
)

Expand Down Expand Up @@ -150,7 +150,7 @@ require (
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
Expand Down Expand Up @@ -197,7 +197,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.14 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/ory/dockertest/v3 v3.10.1-0.20240704115616-d229e74b748d // indirect
github.com/ory/go-convenience v0.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand All @@ -207,7 +207,7 @@ require (
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/seatgeek/logrus-gelf-formatter v0.0.0-20210414080842-5b05eb8ff761 // indirect
Expand All @@ -230,25 +230,25 @@ require (
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.21.0 // indirect
go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 // indirect
go.opentelemetry.io/contrib/samplers/jaegerremote v0.15.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.57.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.32.0 // indirect
go.opentelemetry.io/contrib/propagators/jaeger v1.32.0 // indirect
go.opentelemetry.io/contrib/samplers/jaegerremote v0.26.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.64.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 9cb7782

Please sign in to comment.