2015-07-12 21:43:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
class SimplifyTasks extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2015-07-12 21:43:45 +02:00
|
|
|
$tasks = \App\Models\Task::all();
|
|
|
|
|
|
|
|
foreach ($tasks as $task) {
|
2017-01-30 17:05:31 +01:00
|
|
|
$startTime = strtotime($task->start_time);
|
2017-01-30 20:40:43 +01:00
|
|
|
if (! $task->time_log || ! count(json_decode($task->time_log))) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
Schema::table('tasks', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->dropColumn('start_time');
|
|
|
|
$table->dropColumn('duration');
|
|
|
|
$table->dropColumn('break_duration');
|
|
|
|
$table->dropColumn('resume_time');
|
|
|
|
});
|
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
Schema::table('users', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->boolean('dark_mode')->default(false)->nullable();
|
|
|
|
});
|
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
Schema::table('users', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->dropColumn('theme_id');
|
|
|
|
});
|
2017-01-30 17:05:31 +01:00
|
|
|
}
|
2015-07-12 21:43:45 +02:00
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::table('tasks', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->timestamp('start_time')->nullable();
|
|
|
|
$table->integer('duration')->nullable();
|
|
|
|
$table->timestamp('resume_time')->nullable();
|
|
|
|
$table->integer('break_duration')->nullable();
|
|
|
|
});
|
|
|
|
|
2017-01-30 17:05:31 +01:00
|
|
|
Schema::table('users', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->dropColumn('dark_mode');
|
|
|
|
});
|
2017-01-30 17:05:31 +01:00
|
|
|
Schema::table('users', function ($table) {
|
2015-07-12 21:43:45 +02:00
|
|
|
$table->integer('theme_id')->nullable();
|
|
|
|
});
|
2017-01-30 17:05:31 +01:00
|
|
|
}
|
2015-07-12 21:43:45 +02:00
|
|
|
}
|