laravel create trigger migration
<?php
use Illuminate\Database\Migrations\Migration;
class CreateTrigger extends Migration
{
public function up()
{
DB::unprepared('
CREATE TRIGGER tr_after_main_insert AFTER INSERT ON `main` FOR EACH ROW
BEGIN
INSERT INTO `test`(`new_id`, `type`, `value`, `created_at`) VALUES (NEW.id, NEW.type, 1, NOW());
END
');
}
public function down()
{
DB::unprepared('DROP TRIGGER `tr_after_main_insert`');
}
}