question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `uuid-ossp` extension to postgres automatically

See original GitHub issue

Bug description

When fields of a model contain the attribute

@default(dbgenerated("public.uuid_generate_v4()"))

the migration will fail, unless the SQL

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Has been run on this postgres database before.

How to reproduce

See above

Expected behavior

Migrations that add this attribute to fields should simply add the CREATE EXTENSION SQL before the SQL that attempts to use that extension.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:13
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Jul 4, 2022

“Just make your database user a superuser then!” you say, but I saw in this post that running an application with superuser role is generally not recommended.

If it is just about this: You can use different credentials for running migrations and for running your application.

1reaction
benhicksoncommented, Apr 28, 2021

@janpio It wouldn’t be an exhaustive list initially, but this seems like a pretty popular one (uuid v4), and if other ones come up over time, they could be added too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I install/enable the uuid-ossp extension on Postgres ...
How do I install/enable the uuid-ossp extension? I first verified the contrib package was installed … root@prodbox:/home/rails/myproject# ...
Read more >
Generating a UUID in Postgres for Insert statement?
To install that UUID-related extension, use the CREATE EXTENSION command as seen in this this SQL: CREATE EXTENSION IF NOT EXISTS "uuid-ossp";.
Read more >
Adding UUID functionality to your psql server (uuid-ossp)
Steps · $ psql -U postgres · select * from pg_extension; · # CREATE EXTENSION "uuid-ossp"; · # select * from pg_extension; ·...
Read more >
Documentation: 15: F.49. uuid-ossp - PostgreSQL
The uuid-ossp module provides functions to generate universally unique identifiers (UUIDs) using one of several standard algorithms.
Read more >
The Basics Of PostgreSQL UUID Data Type
We will create a table whose primary key is UUID data type. In addition, the values of the primary key column will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found