mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Convert existing schedules to UTC
This commit is contained in:
57
database/migrations/2020_04_08_172357_alert_schedule_utc.php
Normal file
57
database/migrations/2020_04_08_172357_alert_schedule_utc.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AlertScheduleUtc extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('alert_schedule', function (Blueprint $table) {
|
||||
$table->dateTime('start')->nullable()->default('1970-01-02 00:00:01')->change();
|
||||
$table->dateTime('end')->nullable()->default('1970-01-02 00:00:01')->change();
|
||||
$table->date('start_recurring_dt')->nullable()->change();
|
||||
$table->time('start_recurring_hr')->nullable()->change();
|
||||
$table->time('end_recurring_hr')->nullable()->change();
|
||||
});
|
||||
|
||||
DB::table('alert_schedule')->update([
|
||||
'start' => DB::raw("CONVERT_TZ(start, @@global.time_zone, '+00:00')"),
|
||||
'end' => DB::raw("CONVERT_TZ(end, @@global.time_zone, '+00:00')"),
|
||||
'start_recurring_dt' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(start_recurring_dt, ' '), start_recurring_hr), '%Y-%m-%d %H:%i:%s'), @@global.time_zone, '+00:00'), ' ', 1)"),
|
||||
'start_recurring_hr' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(start_recurring_dt, ' '), start_recurring_hr), '%Y-%m-%d %H:%i:%s'), @@global.time_zone, '+00:00'), ' ', -1)"),
|
||||
'end_recurring_dt' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(end_recurring_dt, ' '), end_recurring_hr), '%Y-%m-%d %H:%i:%s'), @@global.time_zone, '+00:00'), ' ', 1)"),
|
||||
'end_recurring_hr' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(end_recurring_dt, ' '), end_recurring_hr), '%Y-%m-%d %H:%i:%s'), @@global.time_zone, '+00:00'), ' ', -1)"),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::table('alert_schedule')->update([
|
||||
'start' => DB::raw("CONVERT_TZ(start, '+00:00', @@global.time_zone)"),
|
||||
'end' => DB::raw("CONVERT_TZ(end, '+00:00', @@global.time_zone)"),
|
||||
'start_recurring_dt' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(start_recurring_dt, ' '), start_recurring_hr), '%Y-%m-%d %H:%i:%s'), '+00:00', @@global.time_zone), ' ', 1)"),
|
||||
'start_recurring_hr' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(start_recurring_dt, ' '), start_recurring_hr), '%Y-%m-%d %H:%i:%s'), '+00:00', @@global.time_zone), ' ', -1)"),
|
||||
'end_recurring_dt' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(end_recurring_dt, ' '), end_recurring_hr), '%Y-%m-%d %H:%i:%s'), '+00:00', @@global.time_zone), ' ', 1)"),
|
||||
'end_recurring_hr' => DB::raw("SUBSTRING_INDEX(CONVERT_TZ(STR_TO_DATE(CONCAT(CONCAT(end_recurring_dt, ' '), end_recurring_hr), '%Y-%m-%d %H:%i:%s'), '+00:00', @@global.time_zone), ' ', -1)"),
|
||||
]);
|
||||
|
||||
Schema::table('alert_schedule', function (Blueprint $table) {
|
||||
$table->dateTime('start')->nullable(false)->default('1970-01-02 00:00:01')->change();
|
||||
$table->dateTime('end')->nullable(false)->default('1970-01-02 00:00:01')->change();
|
||||
$table->date('start_recurring_dt')->nullable(false)->default('1970-01-01')->change();
|
||||
$table->time('start_recurring_hr')->nullable(false)->default('00:00:00')->change();
|
||||
$table->time('end_recurring_hr')->nullable(false)->default('00:00:00')->change();
|
||||
});
|
||||
}
|
||||
}
|
@@ -101,12 +101,12 @@ alert_schedule:
|
||||
Columns:
|
||||
- { Field: schedule_id, Type: 'int(10) unsigned', 'Null': false, Extra: auto_increment }
|
||||
- { Field: recurring, Type: 'tinyint(1) unsigned', 'Null': false, Extra: '', Default: '0' }
|
||||
- { Field: start, Type: datetime, 'Null': false, Extra: '', Default: '1970-01-02 00:00:01' }
|
||||
- { Field: end, Type: datetime, 'Null': false, Extra: '', Default: '1970-01-02 00:00:01' }
|
||||
- { Field: start_recurring_dt, Type: date, 'Null': false, Extra: '', Default: '1970-01-01' }
|
||||
- { Field: start, Type: datetime, 'Null': true, Extra: '', Default: '1970-01-02 00:00:01' }
|
||||
- { Field: end, Type: datetime, 'Null': true, Extra: '', Default: '1970-01-02 00:00:01' }
|
||||
- { Field: start_recurring_dt, Type: date, 'Null': true, Extra: '', Default: '1970-01-01' }
|
||||
- { Field: end_recurring_dt, Type: date, 'Null': true, Extra: '' }
|
||||
- { Field: start_recurring_hr, Type: time, 'Null': false, Extra: '', Default: '00:00:00' }
|
||||
- { Field: end_recurring_hr, Type: time, 'Null': false, Extra: '', Default: '00:00:00' }
|
||||
- { Field: start_recurring_hr, Type: time, 'Null': true, Extra: '', Default: '00:00:00' }
|
||||
- { Field: end_recurring_hr, Type: time, 'Null': true, Extra: '', Default: '00:00:00' }
|
||||
- { Field: recurring_day, Type: varchar(15), 'Null': true, Extra: '' }
|
||||
- { Field: title, Type: varchar(255), 'Null': false, Extra: '' }
|
||||
- { Field: notes, Type: text, 'Null': false, Extra: '' }
|
||||
|
Reference in New Issue
Block a user