2018-10-07 14:53:52 +02:00
|
|
|
<?php
|
|
|
|
|
2018-10-24 13:35:31 +02:00
|
|
|
namespace Engelsystem\Migrations;
|
|
|
|
|
2018-10-07 14:53:52 +02:00
|
|
|
use Engelsystem\Database\Migration\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
|
|
|
class FixOldTables extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migration
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function up(): void
|
2018-10-07 14:53:52 +02:00
|
|
|
{
|
|
|
|
$connection = $this->schema->getConnection();
|
|
|
|
|
|
|
|
foreach (
|
|
|
|
[
|
|
|
|
'User' => 'CreateDate',
|
|
|
|
'NewsComments' => 'Datum',
|
2019-11-10 23:26:23 +01:00
|
|
|
] as $table => $column
|
|
|
|
) {
|
2018-10-07 14:53:52 +02:00
|
|
|
if (!$this->schema->hasTable($table)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$connection
|
|
|
|
->table($table)
|
|
|
|
->where($column, '<', '0001-01-01 00:00:00')
|
|
|
|
->update([$column => '0001-01-01 00:00:00']);
|
|
|
|
|
2022-12-14 19:15:20 +01:00
|
|
|
$this->schema->table($table, function (Blueprint $table) use ($column): void {
|
2018-10-07 14:53:52 +02:00
|
|
|
$table->dateTime($column)->default('0001-01-01 00:00:00')->change();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migration
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function down(): void
|
2018-10-07 14:53:52 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|