Skip to content

Commit

Permalink
add some timestamps and triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
micha committed Jan 5, 2023
1 parent 2d43520 commit 0dcb652
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function up(): void
$table->integer('jobo_id', true);
$table->integer('jobo_jobe_id')->nullable()->index('FK_job_event_outputs_job_events_jobe_id');
$table->text('jobo_output')->nullable();
$table->dateTime('jobo_db_created')->nullable();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function up(): void
$table->float('jobe_duration', 20, 13)->nullable();
$table->unsignedTinyInteger('jobe_exitcode')->nullable();
$table->dateTime('jobe_db_created')->nullable();
$table->dateTime('jobe_db_changed')->nullable();
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{

public function up(): void
{
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('
CREATE
TRIGGER tr_bi_jobs
BEFORE INSERT
ON jobs
FOR EACH ROW
BEGIN
SET NEW.job_db_created = NOW();
END');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('
CREATE
TRIGGER tr_bi_job_events
BEFORE INSERT
ON job_events
FOR EACH ROW
BEGIN
SET NEW.jobe_db_created = NOW();
END');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('
CREATE
TRIGGER tr_bu_job_events
BEFORE UPDATE
ON job_events
FOR EACH ROW
BEGIN
SET NEW.jobe_db_changed = NOW();
END');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('
CREATE
TRIGGER tr_bi_job_event_outputs
BEFORE INSERT
ON job_event_outputs
FOR EACH ROW
BEGIN
SET NEW.jobo_db_created = NOW();
END');
}


public function down(): void
{
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('DROP TRIGGER tr_bi_jobs');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('DROP TRIGGER tr_bi_job_events');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('DROP TRIGGER tr_bu_job_events');
DB::connection(config('laravel-scheduler-watcher.mysql_connection'))->unprepared('DROP TRIGGER tr_bi_job_event_outputs');
}

};

0 comments on commit 0dcb652

Please sign in to comment.