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

Add explicit support for UUIDs #532

Open
LandonSchropp opened this issue Jan 5, 2018 · 4 comments
Open

Add explicit support for UUIDs #532

LandonSchropp opened this issue Jan 5, 2018 · 4 comments
Labels

Comments

@LandonSchropp
Copy link

LandonSchropp commented Jan 5, 2018

I'm submitting a...


[ ] Bug report  
[x] Feature request

Current behavior

When I add a column with a type of uuid, I get the following warning:

[WARN] Using unknown data type UUID

Expected behavior

I would expect no warning message as long as I have the pgcrypto extension installed.

Minimal reproduction of the problem with instructions

Add a column with a type of uuid.

What is the motivation / use case for changing the behavior?

Personally, I'm a fan of having no warnings in my project. I believe when warnings start piling up that aren't problems, developers begin to ignore them, which causes real issues to be missed. In this case, the uuid type is valid, but db-migrate doesn't recognize it.

Environment

db-migrate version: 0.10.2
db-migrate-pg: 0.2.5
db-migrate-plugin-babel: 1.0.0

Additional information:
- Node version: 9.2
- Platform: Linux (via Docker)

Others:

I believe this issue originally surfaced in #34. I do think allowing pass-through column info is a good idea, but I don't feel like UUIDs should produce warnings.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ezy
Copy link

ezy commented Feb 20, 2019

Postgres requires the "uuid-ossp" extension for this. For anyone who requires it, create a migration with the following:

exports.up = (pgm) => { pgm.createExtension('uuid-ossp') };
exports.down = (pgm) => { pgm.dropExtension('uuid-ossp') };

and from there you can use uuid for id's with a default as follows:

id: { type: 'uuid', primaryKey: true, default: pgm.func('uuid_generate_v4()') },

Hope this helps someone.

@wzrdtales
Copy link
Member

This is a driver issue though. Feel free to add it to the pg driver. Quick lookup showed for me it is not one of the non supported features, so it can be definitely added to the mapping.

@cawel
Copy link

cawel commented Jul 12, 2019

Sadly, @ezy's solution did not work for me. Even with that "uuid-ossp" extension installed, just using 'uuid' as a type for one of my db columns (without using a function for the default value), I still get the warning:

[WARN] Using unknown data type UUID

@IhsanMujdeci
Copy link

What worked for me is
id: { type: 'uuid', primaryKey: true, default: new String('(UUID())') },
This is for mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants