Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID type for hydra_client primary key #2781

Closed
grantzvolsky opened this issue Oct 5, 2021 · 1 comment
Closed

UUID type for hydra_client primary key #2781

grantzvolsky opened this issue Oct 5, 2021 · 1 comment
Assignees

Comments

@grantzvolsky
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Currently, the primary key of the hydra_client table is an integer sequence. Since we don't benefit from the guarantees that a sequence provides, it would be better to just use UUID, to reduce insert complexity[1] and avoid other potential issues[2].

Additional context

The hydra_client table has a public ID (id) and an internal ID (pk, sequential primary key). Other tables reference the public id. The primary key is not used in foreign keys, so it can be changed with minimal disruption in cockroachdb, mysql, and postgres. sqlite requires the table to be recreated.

This change will involve generating new primary keys in application code rather than in the DB because we would like to minimize the work done by the database and it is the standard practice. The migration, however, requires that we generate UUIDs for existing rows, which could be tricky with sqlite or even postgres without an extension.

Describe the solution you'd like

Change hydra_client primary key to UUID while making it possible to revert the change and without imposing any new configuration requirements such as the postgres UUID extension. It is not required for this migration to be online.

Describe alternatives you've considered

Keep using an integer sequence for the hydra_client primary key.

[1] https://www.cockroachlabs.com/docs/stable/create-sequence.html#considerations
[2] #2765

@aeneasr
Copy link
Member

aeneasr commented Oct 5, 2021

👍

grantzvolsky added a commit to grantzvolsky/hydra that referenced this issue Oct 7, 2021
This is the first step towards resolving ory#2781. The issue will be resolved when
we remove the deprecated column.
grantzvolsky added a commit to grantzvolsky/hydra that referenced this issue Feb 7, 2022
grantzvolsky added a commit to grantzvolsky/hydra that referenced this issue Mar 8, 2022
@aeneasr aeneasr closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants