Open LandonSchropp opened 6 years ago
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.
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.
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
What worked for me is
id: { type: 'uuid', primaryKey: true, default: new String('(UUID())') },
This is for mysql
I'm submitting a...
Current behavior
When I add a column with a type of
uuid
, I get the following warning: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, butdb-migrate
doesn't recognize it.Environment
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.