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

Reflect PostgreSQL UUID functionality part of core since v13.0 #45279

Merged
merged 1 commit into from
Jun 7, 2022
Merged

Reflect PostgreSQL UUID functionality part of core since v13.0 #45279

merged 1 commit into from
Jun 7, 2022

Conversation

se2342
Copy link
Contributor

@se2342 se2342 commented Jun 6, 2022

Summary

This change reflects that the SQL function used to generate UUIDs gen_random_uuid () is part of PostgreSQL core beginning with version 13.0. Thus, no special extensions are needed to use UUIDs with PostgreSQL equal or greater version 13.0.

Other Information

See https://www.postgresql.org/docs/current/functions-uuid.html, https://www.postgresql.org/docs/release/13.0/ (look for gen_random_uuid() in release notes) and https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb#L50 for further reference.

@rails-bot rails-bot bot added the docs label Jun 6, 2022
@se2342 se2342 changed the title Update guide to reflect Postgres' UUID functionality part of core since v13.0 Update guides to reflect Postgres' UUID functionality part of core since v13.0 Jun 6, 2022
@@ -325,8 +325,7 @@ SELECT n.nspname AS enum_schema,
* [pgcrypto generator function](https://www.postgresql.org/docs/current/static/pgcrypto.html)
* [uuid-ossp generator functions](https://www.postgresql.org/docs/current/static/uuid-ossp.html)

NOTE: You need to enable the `pgcrypto` (only PostgreSQL >= 9.4) or `uuid-ossp`
extension to use uuid.
NOTE: If you're using PostgresSQL earlier than version 13.0 you may need to enable special extensions to use UUIDs. Enable the `pgcrypto` extension (PostgreSQL >= 9.4) or `uuid-ossp` extension (for even earlier releases).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostgresSQL should be PostgreSQL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. :-)

@yahonda
Copy link
Member

yahonda commented Jun 7, 2022

Would you squash your commits?

@@ -504,7 +503,7 @@ irb> device.id
=> "814865cd-5a1d-4771-9306-4268f188fe9e"
```

NOTE: `gen_random_uuid()` (from `pgcrypto`) is assumed if no `:default` option was
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should not be changed because Rails supports PostgreSQL 9.3 or higher. PostgreSQL versions between 9.3 and 12 need pgcrpyto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the mess, should be good to go now.

@se2342 se2342 changed the title Update guides to reflect Postgres' UUID functionality part of core since v13.0 Reflect PostgreSQL UUID functionality part of core since v13.0 Jun 7, 2022
This change to the guides reflects that the PostgreSQL function used to generate UUIDs `gen_random_uuid ()` is part of PostgreSQL core beginning with version 13.0.

No special extensions are needed for users who want to use UUIDs with PostgreSQL equal or greater version 13.0.

See https://www.postgresql.org/docs/current/functions-uuid.html and https://www.postgresql.org/docs/release/13.0/ (look for `gen_random_uuid()` in release notes) for further reference.
@yahonda
Copy link
Member

yahonda commented Jun 7, 2022

Confirmed this document.

https://www.postgresql.org/docs/release/13.0/

  • Add function gen_random_uuid() to generate version-4 UUIDs (Peter Eisentraut)
    Previously UUID generation functions were only available in the external modules uuid-ossp and pgcrypto.

@yahonda yahonda merged commit ee53454 into rails:main Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants