MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/snap.cafsinfotech.in/database/migrations/2020_02_18_104344_fix_recreate_roles.php
<?php

use Illuminate\Database\Migrations\Migration;

class FixRecreateRoles extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (DB::table('role')->count() > 0) {
            DB::statement('SET FOREIGN_KEY_CHECKS = 0');
            DB::statement('TRUNCATE role');
            DB::statement('TRUNCATE rule');
            DB::statement('SET FOREIGN_KEY_CHECKS = 1');

            Artisan::call('db:seed', ['--class' => 'RoleSeeder']);

            DB::statement('UPDATE users SET role_id = 2 WHERE role_id > 3');
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}