mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Cachet.
|
|
*
|
|
* (c) Alt Three Services Limited
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
use CachetHQ\Cachet\Integrations\Contracts\System;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class AlterTableIncidentsAddOccurredAtColumn extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::table('incidents', function (Blueprint $table) {
|
|
$table->timestamp('occurred_at')->nullable()->after('scheduled_at');
|
|
});
|
|
|
|
// We need a better way of handling data migrations...
|
|
$system = app(System::class);
|
|
$prefix = $system->getTablePrefix();
|
|
|
|
DB::update("UPDATE {$prefix}incidents SET occurred_at = created_at");
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::table('incidents', function (Blueprint $table) {
|
|
$table->dropColumn('occurred_at');
|
|
});
|
|
}
|
|
}
|