-
Notifications
You must be signed in to change notification settings - Fork 88
Add timestamps to Ecto DB table #154
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
Conversation
| # from versions `<= 1.10.0`. | ||
| # | ||
| # https://hexdocs.pm/ecto_sql/Ecto.Migration.html#timestamps/1 | ||
| # | ||
| # If the table has been created with a migration from `>= 1.11.0`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just guessing that this change would necessitate a minor version bump. Note that this PR does not actually change any version numbers.
|
To me, this is good. |
|
Hey @PaulOstazeski, I've had a PR up here for quite some time so until @tompave returns I've created a Hex published fork. You're welcome to raise your pull request there and I'll check it out 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for using the package and for working on this. And apologies for the very late reply.
This change makes sense. Now that I think about it, this should have been present from the start.
| true | ||
|
|
||
| {:error, _} -> | ||
| # Assume error is from timestamp columns not existing, run migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very elegant. 👍
|
Hey @PaulOstazeski, I'm afraid I have to revert this. (revert PR: #160) This weekend I've been catching up on some long overdue maintenance work on this repo, and I think I merged this a bit too quickly. This was my mistake, and I apologize. I'm also afraid that I forgot to run CI on this PR. Normally I have to approve GHA runs for PRs, but it usually presents me a big visible button on the PR page to do so. For some reasons it didn't for this PR. (It could be either because it's been too long since the PR was opened, or because in the meantime I updated the GHA workflow on the master branch.) I thought "sure, it seems safe, I can run it locally", and just merged it. Unfortunately I came across a few issues after that. I think we need to address them before we can consider this to be merged. Normally I'd work on it myself and roll forward, but my time at the moment is limited, and I don't want to leave the master branch in a not-working state, sorry. If you would like to give this another try, here are my observations after testing this locally:
On the last two points, I suppose that my main concern is: if I add this functionality to the package, then the upgrade path should be smooth and painless. If it requires too many manual steps, and it comes with risks, then I'd be more inclined to add it to the next major version, rather than a minor version bump. I hope it makes sense! |
|
Thanks @tompave, I definitely missed some subtleties here. I'll take another crack at it and see if I can address these. |
This adds
inserted_atandupdated_atcolumns to the database table when using Ecto, and uses the built-in Ecto behavior to populate their values without any additional work. This makes it possible to directly measure how long a given flag has been in its current state, which in turn makes it easier to determine when a flag is safe to be removed (i.e. that it has been "on" for some/many/all users for "long enough" that we haven't observed any downsides).