You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
985 B
PHTML
42 lines
985 B
PHTML
6 years ago
|
<?php
|
||
|
|
||
|
use Engelsystem\Database\Migration\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
|
||
|
class FixOldTables extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migration
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
$connection = $this->schema->getConnection();
|
||
|
|
||
|
foreach (
|
||
|
[
|
||
|
'User' => 'CreateDate',
|
||
|
'NewsComments' => 'Datum',
|
||
|
] as $table => $column) {
|
||
|
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']);
|
||
|
|
||
|
$this->schema->table($table, function (Blueprint $table) use ($column) {
|
||
|
$table->dateTime($column)->default('0001-01-01 00:00:00')->change();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migration
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
}
|
||
|
}
|