Save the date that a migration was applied #43079
Unanswered
lucraraujo
asked this question in
Q&A
Replies: 3 comments 3 replies
-
If you have setup a CI of some sort, you could find the release date? |
Beta Was this translation helpful? Give feedback.
2 replies
-
If you are using MySQL or MariaDB you can add a field With sql ALTER TABLE migrations ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP; Or with migration $table->timestamp('created_at')->useCurrent(); |
Beta Was this translation helpful? Give feedback.
0 replies
-
I created the following migration: <?php
declare(strict_types=1);
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('migrations', static function (Blueprint $table): void {
$table->dateTime('created_at')->nullable()->default(Carbon::now());
});
}
public function down(): void
{
Schema::table('migrations', static function (Blueprint $table): void {
$table->dropColumn('created_at');
});
}
}; I work with SQL Server but I can't see a reason that it will not work in other DBs. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm investigating a bug in a application and a possible solution for the bug was DB change made by a migration.
Since the date the migration was created does not matter much I searched for the date the migration was applied. But, since the migration table does not save such data, I wonder if it is there is a place I can go the check this information.
If there is none, I suggest implement a timestamp on the migration table to register the date it was applied.
Beta Was this translation helpful? Give feedback.
All reactions