Skip to content

Could not migrate from os10-os12 #1502

Closed
@singlewind

Description

Describe the bug

Run hydra migrate sql -e --yes failed in the middle

Reproducing the bug

Steps to reproduce the behavior:

  1. Existing database from os10.rc6
  2. Download hydra v1.0.0 os12
  3. Run following command
hydra migrate sql -e
INFO[0000] No tracer configured - skipping tracing setup
INFO[0000] Connecting with mysql://*:*@tcp(192.168.10.10:3306)/hydra?
INFO[0000] Connected to SQL!
The following migration is planned:

| DRIVER |      MODULE       |   ID   | # |                                       QUERY                                        |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 13.sql | 0 | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | frontchannel_logout_uri TEXT                                                       |
|        |                   |        |    | NULL; ALTER TABLE hydra_client                                                     |
|        |                   |        |    | ADD frontchannel_logout_uri                                                        |
|        |                   |        |    | TEXT NULL;                                                                         |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | OAuth 2.0 Clients | 13.sql | 1 | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | frontchannel_logout_session_required                                               |
|        |                   |        |    | BOOL NOT NULL DEFAULT FALSE;                                                       |
|        |                   |        |    | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | frontchannel_logout_session_required                                               |
|        |                   |        |    | BOOL NOT NULL DEFAULT FALSE;                                                       |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | Login &Consent    | 13.sql | 2 | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | post_logout_redirect_uris TEXT                                                     |
|        |                   |        |    | NULL; ALTER TABLE hydra_client                                                     |
|        |                   |        |    | ADD post_logout_redirect_uris                                                      |
|        |                   |        |    | TEXT NULL;                                                                         |
|        |-------------------|        |---|------------------------------------------------------------------------------------|
|        | OAuth 2.0         |        | 3 | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | backchannel_logout_uri TEXT                                                        |
|        |                   |        |    | NULL; ALTER TABLE hydra_client                                                     |
|        |                   |        |    | ADD backchannel_logout_uri                                                         |
|        |                   |        |    | TEXT NULL;                                                                         |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 13.sql | 4 | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | backchannel_logout_session_required                                                |
|        |                   |        |    | BOOL NOT NULL DEFAULT FALSE;                                                       |
|        |                   |        |    | ALTER TABLE hydra_client ADD                                                       |
|        |                   |        |    | backchannel_logout_session_required                                                |
|        |                   |        |    | BOOL NOT NULL DEFAULT FALSE;                                                       |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 13.sql | 5 | UPDATE hydra_client SET                                                            |
|        |                   |        |    | frontchannel_logout_uri='',post_logout_redirect_uris='',backchannel_logout_uri=''; |
|        |                   |        |    | UPDATE hydra_client SET                                                            |
|        |                   |        |    | frontchannel_logout_uri='',post_logout_redirect_uris='',backchannel_logout_uri=''; |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 13.sql | 6 | ALTER TABLE hydra_client                                                           |
|        |                   |        |    | MODIFY frontchannel_logout_uri                                                     |
|        |                   |        |    | TEXT NOT NULL; ALTER                                                               |
|        |                   |        |    | TABLE hydra_client MODIFY                                                          |
|        |                   |        |    | frontchannel_logout_uri TEXT                                                       |
|        |                   |        |    | NOT NULL;                                                                          |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 13.sql | 7 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_client MODIFY                                                                |
|        |                   |        |    | post_logout_redirect_uris                                                          |
|        |                   |        |    | TEXT NOT NULL; ALTER                                                               |
|        |                   |        |    | TABLE hydra_client MODIFY                                                          |
|        |                   |        |    | post_logout_redirect_uris TEXT                                                     |
|        |                   |        |    | NOT NULL;                                                                          |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 13.sql | 8 | ALTER TABLE hydra_client                                                           |
|        |                   |        |    | MODIFY backchannel_logout_uri                                                      |
|        |                   |        |    | TEXT NOT NULL; ALTER                                                               |
|        |                   |        |    | TABLE hydra_client MODIFY                                                          |
|        |                   |        |    | backchannel_logout_uri TEXT                                                        |
|        |                   |        |    | NOT NULL;                                                                          |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 8.sql  | 0 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | ADD context TEXT NULL; ALTER TABLE                                                 |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | ADD context TEXT NULL;                                                             |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | OAuth 2.0 Clients | 8.sql  | 1 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | ADD context TEXT                                                                   |
|        |                   |        |    | NULL; ALTER TABLE                                                                  |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | ADD context TEXT NULL;                                                             |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | Login &Consent    | 8.sql  | 2 | UPDATE                                                                             |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | SET context='{}'; UPDATE                                                           |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | SET context='{}';                                                                  |
|        |-------------------|        |---|------------------------------------------------------------------------------------|
|        | OAuth 2.0         |        | 3 | UPDATE                                                                             |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | SET context='{}'; UPDATE                                                           |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | SET context='{}';                                                                  |
|        |-------------------|        |---|------------------------------------------------------------------------------------|
|        |                   |        | 4 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | MODIFY context TEXT NOT NULL; ALTER TABLE                                          |
|        |                   |        |    | hydra_oauth2_authentication_request_handled                                        |
|        |                   |        |    | MODIFY context TEXT NOT NULL;                                                      |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  |                   | 8.sql  | 5 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | MODIFY context TEXT                                                                |
|        |                   |        |    | NOT NULL; ALTER TABLE                                                              |
|        |                   |        |    | hydra_oauth2_consent_request                                                       |
|        |                   |        |    | MODIFY context TEXT NOT NULL;                                                      |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 9.sql  | 0 | CREATE TABLE                                                                       |
|        |                   |        |    | hydra_oauth2_logout_request                                                        |
|        |                   |        |    | ( challenge varchar(36) NOT                                                        |
|        |                   |        |    | NULL PRIMARY KEY, verifier                                                         |
|        |                   |        |    | varchar(36) NOT NULL, subject                                                      |
|        |                   |        |    | varchar(255) NOT NULL,                                                             |
|        |                   |        |    | sid varchar(36) NOT NULL,                                                          |
|        |                   |        |    | client_id varchar(255) NOT                                                         |
|        |                   |        |    | NULL, request_url text NOT                                                         |
|        |                   |        |    | NULL, redir_url text NOT NULL,                                                     |
|        |                   |        |    | was_used bool NOT NULL default                                                     |
|        |                   |        |    | false, accepted bool NOT                                                           |
|        |                   |        |    | NULL default false, rejected                                                       |
|        |                   |        |    | bool NOT NULL default false,                                                       |
|        |                   |        |    | rp_initiated bool NOT NULL                                                         |
|        |                   |        |    | default false ); CREATE TABLE                                                      |
|        |                   |        |    | hydra_oauth2_logout_request                                                        |
|        |                   |        |    | ( challenge varchar(36) NOT                                                        |
|        |                   |        |    | NULL PRIMARY KEY, verifier                                                         |
|        |                   |        |    | varchar(36) NOT NULL, subject                                                      |
|        |                   |        |    | varchar(255) NOT NULL,                                                             |
|        |                   |        |    | sid varchar(36) NOT NULL,                                                          |
|        |                   |        |    | client_id varchar(255) NOT                                                         |
|        |                   |        |    | NULL, request_url text NOT                                                         |
|        |                   |        |    | NULL, redir_url text NOT NULL,                                                     |
|        |                   |        |    | was_used bool NOT NULL default                                                     |
|        |                   |        |    | false, accepted bool NOT                                                           |
|        |                   |        |    | NULL default false, rejected                                                       |
|        |                   |        |    | bool NOT NULL default false,                                                       |
|        |                   |        |    | rp_initiated bool NOT NULL                                                         |
|        |                   |        |    | default false );                                                                   |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 10.sql | 0 | CREATE UNIQUE INDEX                                                                |
|        |                   |        |    | hydra_oauth2_logout_request_veri_idx                                               |
|        |                   |        |    | ON hydra_oauth2_logout_request                                                     |
|        |                   |        |    | (verifier); CREATE UNIQUE INDEX                                                    |
|        |                   |        |    | hydra_oauth2_logout_request_veri_idx                                               |
|        |                   |        |    | ON hydra_oauth2_logout_request                                                     |
|        |                   |        |    | (verifier);                                                                        |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | OAuth 2.0 Clients | 10.sql | 1 | ALTER TABLE hydra_oauth2_logout_request                                            |
|        |                   |        |    | ADD CONSTRAINT                                                                     |
|        |                   |        |    | hydra_oauth2_logout_request_client_id_fk                                           |
|        |                   |        |    | FOREIGN KEY (client_id) REFERENCES                                                 |
|        |                   |        |    | hydra_client(id) ON DELETE CASCADE;                                                |
|        |                   |        |    | ALTER TABLE hydra_oauth2_logout_request                                            |
|        |                   |        |    | ADD CONSTRAINT                                                                     |
|        |                   |        |    | hydra_oauth2_logout_request_client_id_fk                                           |
|        |                   |        |    | FOREIGN KEY (client_id) REFERENCES                                                 |
|        |                   |        |    | hydra_client(id) ON DELETE CASCADE;                                                |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 11.sql | 0 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_authentication_session                                                |
|        |                   |        |    | ADD remember bool NOT NULL                                                         |
|        |                   |        |    | DEFAULT FALSE; ALTER TABLE                                                         |
|        |                   |        |    | hydra_oauth2_authentication_session                                                |
|        |                   |        |    | ADD remember bool NOT NULL DEFAULT                                                 |
|        |                   |        |    | FALSE;                                                                             |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | OAuth 2.0 Clients | 11.sql | 1 | UPDATE                                                                             |
|        |                   |        |    | hydra_oauth2_authentication_session                                                |
|        |                   |        |    | SET remember=TRUE; UPDATE                                                          |
|        |                   |        |    | hydra_oauth2_authentication_session                                                |
|        |                   |        |    | SET remember=TRUE;                                                                 |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|
| mysql  | JSON Web Keys     | 12.sql | 0 | ALTER TABLE                                                                        |
|        |                   |        |    | hydra_oauth2_logout_request                                                        |
|        |                   |        |    | MODIFY client_id varchar(255)                                                      |
|        |                   |        |    | NULL DEFAULT NULL; ALTER TABLE                                                     |
|        |                   |        |    | hydra_oauth2_logout_request                                                        |
|        |                   |        |    | MODIFY client_id varchar(255)                                                      |
|        |                   |        |    | NULL DEFAULT NULL;                                                                 |
|--------|-------------------|--------|---|------------------------------------------------------------------------------------|

To skip the next question use flag --yes (at your own risk).
Do you wish to execute this migration plan? [y/n]: y
An error occurred while connecting to SQL: Could not migrate sql schema, applied 2 migrations: Error 1215: Cannot add foreign key constraint handling 10

Server logs

Error 1215: Cannot add foreign key constraint handling 10

Server configuration

Expected behavior

Can be migrated successfully.

Environment

  • Version: v1.0.0
  • Environment: Mac, Docker, ...

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions