sequelize-auto
sequelize-auto copied to clipboard
Use sequelize.now instead of current_timestamp
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 .
After I have changed it to sequelize.now() it didn't throw an error anymore.
@crephix what's the generated model that's throwing this error?
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
Since I experience the problem again in another project here is another model with this issue: https://ghostbin.com/paste/7dnrr
This should be fixed as I have the same issue.
Is this still a problem in [email protected] and the latest sequelize?