1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 09:21:34 +02:00
invoiceninja/database/migrations/2015_07_08_114333_simplify_tasks.php

67 lines
1.9 KiB
PHP
Raw Normal View History

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-06-19 13:19:25 +02:00
if (Schema::hasColumn('users', 'dark_mode')) {
2017-04-06 20:48:56 +02:00
Schema::table('users', function ($table) {
$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
}