framework icon indicating copy to clipboard operation
framework copied to clipboard

Add created_at Datetime Column To Migrations

Open nickescobedo opened this issue 1 year ago • 5 comments

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 avatar Oct 11 '24 11:10 nickescobedo

Why not stick with the created_at naming?

rodrigopedra avatar Oct 11 '24 11:10 rodrigopedra

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 avatar Oct 11 '24 11:10 nickescobedo

Does anyone have an idea why the tests are failing?

Even if I removed my changes the tests were failing.

nickescobedo avatar Oct 11 '24 11:10 nickescobedo

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.

johanrosenson avatar Oct 14 '24 13:10 johanrosenson

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

ziadoz avatar Oct 14 '24 18:10 ziadoz