Answers for "laravel migrating"

PHP
2

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`');
    }
}
Posted by: Guest on June-23-2021
2

Laravel Migrations from an existing database

To Generate Laravel Migrations from an existing database.
  
Use the following package.
  
https://github.com/Xethron/migrations-generator
Posted by: Guest on June-19-2021

Code answers related to "laravel migrating"

Browse Popular Code Answers by Language