Skip to content

Migration fails on CockroachDB v25.1.2 #3964

@mihed

Description

@mihed

Preflight checklist

Ory Network Project

No response

Describe the bug

The migration fails on v25.1.2, but works perfectly on v24.3.8.

Reproducing the bug

Run your cockroach image somewhere and export DSN:

export DSN=cockroach://$(CRDB_USER):$(CRDB_PASSWORD)@$(dbHost):26257/$(dbName)?sslmode=require

hydra migrate sql -e --yes

Relevant log output

hydra-migration-phngm hydra ------------ ERROR ------------
hydra-migration-phngm hydra Could not apply migrations:
hydra-migration-phngm hydra ERROR: relation "hydra_client" (111): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction (SQLSTATE 0A000)
hydra-migration-phngm hydra error executing migrations/20211004110003000000_change_client_primary_key.cockroach.up.sql, sql: ALTER TABLE hydra_client DROP CONSTRAINT "primary";
hydra-migration-phngm hydra ALTER TABLE hydra_client ADD CONSTRAINT "hydra_client_pkey" PRIMARY KEY (pk);
hydra-migration-phngm hydra 
hydra-migration-phngm hydra github.com/ory/x/popx.NewMigrationBox.func1.1
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migration_box.go:160
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).UpTo.func1.2
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:145
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).isolatedTransaction
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:362
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).UpTo.func1
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:144
hydra-migration-phngm hydra github.com/cockroachdb/cockroach-go/v2/crdb.Execute
hydra-migration-phngm hydra     /go/pkg/mod/github.com/cockroachdb/cockroach-go/[email protected]/crdb/tx.go:96
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).exec.func2
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:613
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).exec
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:617
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).UpTo
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:96
hydra-migration-phngm hydra github.com/ory/x/popx.(*Migrator).Up
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/migrator.go:85
hydra-migration-phngm hydra github.com/ory/hydra/v2/persistence/sql.(*Persister).MigrateUp
hydra-migration-phngm hydra     /project/persistence/sql/persister_migration.go:51
hydra-migration-phngm hydra github.com/ory/x/popx.MigrateSQLUp
hydra-migration-phngm hydra     /go/pkg/mod/github.com/ory/[email protected]/popx/cmd.go:113
hydra-migration-phngm hydra github.com/ory/hydra/v2/cmd/cli.(*MigrateHandler).MigrateSQLUp
hydra-migration-phngm hydra     /project/cmd/cli/handler_migrate.go:321
hydra-migration-phngm hydra github.com/spf13/cobra.(*Command).execute
hydra-migration-phngm hydra     /go/pkg/mod/github.com/spf13/[email protected]/command.go:985
hydra-migration-phngm hydra github.com/spf13/cobra.(*Command).ExecuteC
hydra-migration-phngm hydra     /go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
hydra-migration-phngm hydra github.com/spf13/cobra.(*Command).Execute
hydra-migration-phngm hydra     /go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
hydra-migration-phngm hydra github.com/ory/hydra/v2/cmd.Execute
hydra-migration-phngm hydra     /project/cmd/root.go:105
hydra-migration-phngm hydra main.main
hydra-migration-phngm hydra     /project/main.go:14
hydra-migration-phngm hydra runtime.main
hydra-migration-phngm hydra     /usr/local/go/src/runtime/proc.go:272
hydra-migration-phngm hydra runtime.goexit
hydra-migration-phngm hydra     /usr/local/go/src/runtime/asm_amd64.s:1700

Relevant configuration

Version

v2.3.0

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes

Additional Context

The exact images used:

Db:
image: cockroachdb/cockroach
tag: "amd64-v25.1.2"

ory-hydra:
image: oryd/hydra
tag: "v2.3.0-amd64-distroless"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions