Answers for "laravel drop all tables and migrate"

PHP
0

Laravel Drop All Tables & Migrate

php artisan migrate:fresh

php artisan migrate:fresh --seed
Posted by: Guest on May-04-2021
1

laravel db drop table

//Get all the table names
$all_table_names = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();

foreach ($all_table_names as $name) {
    //if you don't want to truncate migrations in Database
    if ($name == 'migrations') {
        continue;
    }
    DB::table($name)->truncate();
}
Posted by: Guest on January-08-2022
0

delete rows by migration laravel

Comment::where('post_id',$id)->delete();

// in down migration

    public function down()
    {
        Schema::table('package_types', function (Blueprint $table) {
            \App\Models\PackageType::query()->where('id','gt',1)->delete();
        });
    }
Posted by: Guest on August-14-2021

Code answers related to "laravel drop all tables and migrate"

Browse Popular Code Answers by Language