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

Add created_at Datetime Column To Migrations #53114

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nickescobedo
Copy link

@nickescobedo nickescobedo commented Oct 11, 2024

Add executed_at date time column to the migrations table and fill it with the current time when the migration is run.

This sort of feature will be extremely helpful for larger teams to know when a particular migration ran. Having the date time will help with debugging if there is a bad migration. The time can then be used to correlate other things happening throughout the app or figure out who ran the migration.

Having access to more information without the user having to do anything seems like a win-win. Upgrading to Laravel 12 means they would have to add the column, but that is a simple migration and it's been done before when the ID column was added.

@nickescobedo nickescobedo marked this pull request as draft October 11, 2024 11:22
@rodrigopedra
Copy link
Contributor

Why not stick with the created_at naming?

@nickescobedo
Copy link
Author

Why not stick with the created_at naming?

Sounds fine to me. My thought process was the name executed is a bit more descriptive, but people are definitely used to created_at.

@nickescobedo nickescobedo changed the title Add Datetime Column To Migrations Add created_at Datetime Column To Migrations Oct 11, 2024
@nickescobedo
Copy link
Author

Does anyone have an idea why the tests are failing?

Even if I removed my changes the tests were failing.

@johanrosenson
Copy link
Contributor

johanrosenson commented Oct 14, 2024

how is the backwards compatibility on this? will this force everyone to update their migrations table?
I think it would be good if the code could keep working even if created_at column is missing.

@ziadoz
Copy link
Contributor

ziadoz commented Oct 14, 2024

Could you achieve this without any code changes by using $table->timestamp('created_at')->useCurrent()?

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

Successfully merging this pull request may close these issues.

4 participants