loopbackio / loopback-connector-mysql

Loopback Connector for MySQL
Other
125 stars 183 forks source link

Support default value in migrations and discovery #112

Closed mrkswrnr closed 7 years ago

mrkswrnr commented 9 years ago

Currently COLUMN_DEFAULT of information_schema.columns is being ignored in discovery. Also there is no migration-metadata being created as in loopback-connector-postgresql.

PaddyMann commented 8 years ago

Frustratingly the postgresql connector supports dbDefault and the mysql connector does not.

The most common use-case for a default value is timestamping:

createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
updatedAt TIMESTAMP NULL DEFAULT DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

Without this, we have to resort to creating mixins for setting the timestamps. Well then, there's a simple workaround you say! Not so, the recommended https://github.com/clarkbw/loopback-ds-timestamp-mixin hasn't managed to find a solution that works with validateUpsert: true (which is a must-have for many projects).

This DB setting should be simple and is instead costing a ridiculous amount of time and hair pulling, so would love to see it added :)

shaheero commented 7 years ago

Anyone reached a good workaround yet?

jannyHou commented 7 years ago

This feature should be similar to function columnDbDefault in postgresql.

b-admike commented 7 years ago

Tracked in https://github.com/strongloop/loopback-connector-mysql/issues/320.