sequelize-auto icon indicating copy to clipboard operation
sequelize-auto copied to clipboard

Use sequelize.now instead of current_timestamp

Open crephix opened this issue 9 years ago • 5 comments

Hello, I think sequelize-auto should use sequelize.now instead of current_timestamp as default value for the models because otherwise sequelize will throw an excpeption/warning:

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info. Arguments: [object Object] Error at Function.createFromInputFallback (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:271:105) at configFromString (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1169:32) at configFromInput (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1675:13) at prepareConfig (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1658:13) at createFromConfig (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1625:44) at createLocalOrUTC (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1707:16) at local__createLocal (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:1711:16) at utils_hooks__hooks (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\moment\moment.js:16:29) at DATE.$applyTimezone (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\data-types.js:473:14) at DATE.$stringify (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\dialects\mysql\data-types.js:34:37) at ABSTRACT.stringify (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\data-types.js:77:17) at Object.QueryGenerator.escape (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\dialects\abstract\query-generator.js:966:32) at Object.QueryGenerator.insertQuery (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\dialects\abstract\query-generator.js:298:28) at QueryInterface.insert (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\query-interface.js:497:33) at . (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\sequelize\lib\instance.js:670:56) at tryCatcher (C:\Users\h9pe\WebstormProjects\AuthServerWebSockets\node_modules\bluebird\js\release\util.js:16:23)

After I have changed it to sequelize.now() it didn't throw an error anymore.

crephix avatar Jun 14 '16 15:06 crephix

@crephix what's the generated model that's throwing this error?

durango avatar Jun 22 '16 13:06 durango

This will happen for any database model which uses "current_timestamp" (in mysql at least) and is generated by sequelize-auto. Currently I don't have access to the originally created model by sequelize auto. If this is necessary to further investigate the issue, please let me know then I will create a new MySQL table which has a timestamp field and current_timestamp as default value

crephix avatar Jun 24 '16 08:06 crephix

Since I experience the problem again in another project here is another model with this issue: https://ghostbin.com/paste/7dnrr

crephix avatar Jun 29 '16 15:06 crephix

This should be fixed as I have the same issue.

sovietspaceship2 avatar Sep 25 '17 09:09 sovietspaceship2

Is this still a problem in [email protected] and the latest sequelize?

steveschmitt avatar Jul 10 '20 22:07 steveschmitt