1<?php
2
3use Illuminate\Database\Migrations\Migration;
4
5class CreateTrigger extends Migration
6{
7 public function up()
8 {
9 DB::unprepared('
10 CREATE TRIGGER tr_after_main_insert AFTER INSERT ON `main` FOR EACH ROW
11 BEGIN
12 INSERT INTO `test`(`new_id`, `type`, `value`, `created_at`) VALUES (NEW.id, NEW.type, 1, NOW());
13 END
14 ');
15 }
16
17 public function down()
18 {
19 DB::unprepared('DROP TRIGGER `tr_after_main_insert`');
20 }
21}