Hydra: migration 0.9.x -> 1.0: sector_identifier_uri contains null values

Created on 11 Jul 2018  路  3Comments  路  Source: ory/hydra

While migrating from 0.9.12 to v1.0.0-beta.5 the migration fails with

An error occurred while running the migrations: 
Could not apply `client` SQL migrations: Could not migrate sql schema, 
applied 1 migrations: pq: column "sector_identifier_uri" contains null values
 ```

I'ts probably due to https://github.com/ory/hydra/blob/v1.0.0-beta.5/client/manager_sql.go#L74

It tries to alter the table, the field is set `NOT NULL` but there are already rows in the table, and it fails because they would end up with NULL values.

You should probably set a default value, like

ALTER TABLE hydra_client ADD sector_identifier_uri TEXT NOT NULL DEFAULT ''


or do an update in three steps, like

ALTER TABLE hydra_client ADD sector_identifier_uri TEXT NULL;
UPDATE hydra_client SET sector_identifier_uri='';
ALTER TABLE hydra_client ALTER COLUMN sector_identifier_uri TEXT NOT NULL;
```

bug packagclient

Most helpful comment

This is how we roll! :D --> #919

All 3 comments

Hey, thanks for the report :) A fix will be available soon (already working on one) and it will also add a test suite which will run the migrations and add data after each migration step, so this doesn't happen any more (hopefully)!

Wow, that was quick

This is how we roll! :D --> #919

Was this page helpful?
0 / 5 - 0 ratings