1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00
invoiceninja/database/migrations/2015_07_08_114333_simplify_tasks.php
2019-01-30 22:25:37 +11:00

67 lines
1.9 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
class SimplifyTasks extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tasks = \App\Models\Task::all();
foreach ($tasks as $task) {
$startTime = strtotime($task->start_time);
if (! $task->time_log || ! count(json_decode($task->time_log))) {
$task->time_log = json_encode([[$startTime, $startTime + $task->duration]]);
$task->save();
} elseif ($task->getDuration() != intval($task->duration)) {
$task->time_log = json_encode([[$startTime, $startTime + $task->duration]]);
$task->save();
}
}
Schema::table('tasks', function ($table) {
$table->dropColumn('start_time');
$table->dropColumn('duration');
$table->dropColumn('break_duration');
$table->dropColumn('resume_time');
});
Schema::table('users', function ($table) {
$table->boolean('dark_mode')->default(false)->nullable();
});
Schema::table('users', function ($table) {
$table->dropColumn('theme_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tasks', function ($table) {
$table->timestamp('start_time')->nullable();
$table->integer('duration')->nullable();
$table->timestamp('resume_time')->nullable();
$table->integer('break_duration')->nullable();
});
if (Schema::hasColumn('users', 'dark_mode')) {
Schema::table('users', function ($table) {
$table->dropColumn('dark_mode');
});
}
Schema::table('users', function ($table) {
$table->integer('theme_id')->nullable();
});
}
}