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

chore: Update Sequelize to v6 #1085

Merged
merged 2 commits into from
Mar 18, 2021

Conversation

cicoub13
Copy link
Contributor

@cicoub13 cicoub13 commented Mar 1, 2021

From v4 to v5:

  • operatorsAliases is deprecated
  • sequelize.close is not needed anymore, but I let it by security

From v5 to v6:

  • nothing particular

Due to sequelize/sequelize#11225, I added aliases for created_at and updated_athere : https://github.com/GladysAssistant/Gladys/pull/1085/files#diff-183dfcbb2c260fee7e3468389eaf038313e4ef51d52a3d8627590ba8daab4ce8R9

Can you please double check server/package-lock.json ? I don't know how to update only sequelize ?

@cicoub13 cicoub13 force-pushed the chore-update-sequelize branch from ec49380 to cd75885 Compare March 1, 2021 21:35
@VonOx VonOx added the dependencies Pull requests that update a dependency file label Mar 1, 2021
@codecov
Copy link

codecov bot commented Mar 1, 2021

Codecov Report

Merging #1085 (06a5fa4) into master (0ae38b9) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1085   +/-   ##
=======================================
  Coverage   95.56%   95.56%           
=======================================
  Files         531      531           
  Lines        7123     7123           
=======================================
  Hits         6807     6807           
  Misses        316      316           
Impacted Files Coverage Δ
server/config/config.js 100.00% <ø> (ø)
server/seeders/20190205070000-house.js 100.00% <100.00%> (ø)
server/seeders/20190205071039-demo-user.js 100.00% <100.00%> (ø)
server/seeders/20190211053203-demo-location.js 100.00% <100.00%> (ø)
server/seeders/20190219041452-message.js 100.00% <100.00%> (ø)
server/seeders/20190226025926-service.js 100.00% <100.00%> (ø)
server/seeders/20190226025931-variable.js 100.00% <100.00%> (ø)
server/seeders/20190227043234-scene.js 100.00% <100.00%> (ø)
server/seeders/20190227081653-room.js 100.00% <100.00%> (ø)
server/seeders/20190227081656-device.js 100.00% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ae38b9...06a5fa4. Read the comment docs.

@Pierre-Gilles
Copy link
Contributor

Due to this issue sequelize/sequelize#2641, we used created_at and update_at in Javascript objects but like the issue is fixed, fields are now createdAt and updateAt (columns in database stay the same)

Are you 100% sure the "underscored" option could not work like before?

We use snake_case for all database columns, I'm not sure we want to move to camelCase. It's weird to mix snake_case and camelCase in same objects...

@cicoub13 cicoub13 force-pushed the chore-update-sequelize branch from cd75885 to cb984f9 Compare March 8, 2021 22:33
Copy link
Contributor

@atrovato atrovato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enought for me.
Tested with existing database, and with blank one. All migrations are well applied.

@cicoub13
Copy link
Contributor Author

Are you 100% sure the "underscored" option could not work like before?

We use snake_case for all database columns, I'm not sure we want to move to camelCase. It's weird to mix snake_case and camelCase in same objects...

Sorry. I mixed two issues. With underscore option, everything stays snake_case.

@Pierre-Gilles
Copy link
Contributor

Pierre-Gilles commented Mar 15, 2021

sequelize.close is not needed anymore, but I let it by security

Ah, I don't know if you saw my last PR, my I added this:

https://github.com/GladysAssistant/Gladys/blob/master/server/index.js#L29

You say it's not needed anymore with Sequelize v6 ?

From the doc, I see that it's still in the doc:

Screenshot 2021-03-15 at 10 26 09

@cicoub13
Copy link
Contributor Author

cicoub13 commented Mar 15, 2021

I'm confuse. Documentation here https://sequelize.org/master/manual/connection-pool.html says that

Sequelize will set up a connection pool on initialization

and here https://sequelize.org/v5/manual/upgrade-to-v5.html#pooling that

You no longer need to call sequelize.close to shutdown pool

But I let the close() I found in the shutdown file.

https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-method-close

Normally this is done on process exit, so you only need to call this method if you are creating multiple instances, and want to garbage collect some of them.

@Pierre-Gilles
Copy link
Contributor

They are talking about connection pooling only :) As we use Sqlite, there is no pooling (I guess), and I think closing the DB before stopping Gladys is safer to avoid letting the DB in a bad state

@Pierre-Gilles Pierre-Gilles merged commit f8d597a into GladysAssistant:master Mar 18, 2021
@cicoub13 cicoub13 deleted the chore-update-sequelize branch May 15, 2021 16:32
Jean-PhilippeD pushed a commit to Jean-PhilippeD/Gladys that referenced this pull request Oct 13, 2021
Co-authored-by: Pierre-Gilles Leymarie <pierregilles.leymarie@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants