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

fix: This ensure that all timestamps in ecto are :utc_datetime #94

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

Nesqwik
Copy link
Member

@Nesqwik Nesqwik commented Feb 23, 2022

This might (or might not) fix #92
I'm unable to reproduce the error locally but since we now ask ecto to use timestamps with timezone, all timezone error should be fixed... hopefully...

I've used a custom Lenra.Schema for every schema with default :utc_datetime & configure ecto to get :utc_datetime in migration for all future migrations. Then i've change all current table to use :utc_datetime instead of :naive_datetime for updated_at and inserted_at columns.

@Nesqwik Nesqwik requested review from jonas-martinez and shiipou and removed request for jonas-martinez February 23, 2022 09:31
@@ -16,6 +16,8 @@ import Config
config :lenra,
ecto_repos: [Lenra.Repo]

config :lenra, Lenra.Repo, migration_timestamps: [type: :utc_datetime]
Copy link
Collaborator

@jonas-martinez jonas-martinez Feb 23, 2022

Choose a reason for hiding this comment

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

You set this config line but I cannot see where this is used, can you give me some insight @Nesqwik ? (You already set it in the schema.ex file)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure !
There is two config that have to be done :

  • The first one, this one, is the Migration configuration. This tell to ecto to use :utc_datetime by default for timestamps() macro in migration (in postgres table) instead of the :naive_datetime.
  • The second one in schema.ex ask the schema (Elixir representation of the tables) to retrieve the field in the database into a DateTime instead of NaiveDateTime.

The difference is that DateTime contain the timezone information and NaiveDateTime doesn't. This should help us with all the timezone issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Nesqwik Nesqwik merged commit 454ebaf into beta Feb 23, 2022
@Nesqwik Nesqwik deleted the timezone-timestamp-issue branch February 23, 2022 12:52
@shiipou
Copy link
Contributor

shiipou commented Feb 23, 2022

🎉 This PR is included in version 1.0.0-beta.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

@shiipou
Copy link
Contributor

shiipou commented Apr 4, 2023

🎉 This PR is included in version 1.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@taorepoara
Copy link
Member

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timezone issue on inserted_at for password code
4 participants