Skip to content
Advertisement

migrating a specific table in laravel

using command php artisan migrate migrates all the tables. but i have employees table that i migrated along with other tables. but it is not migrated (i cannot see it in phpmyadmin). now when i again use php artisan migrate command it displays nothing to migrate. How can i migrate that specific employees table?

<?php

use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;

class Employees extends Migration
{
    public function up()
    {
        Schema::create('employees', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('contact_number');
            $table->timestamps();       
        });

        $faker = FakerFactory::create();

        $limit = 33;

        for ($i = 0; $i < $limit; $i++) {
            DB::table('employees')->insert([ //,
                'name' => $faker->name,
                'email' => $faker->unique()->email,
                'contact_number' => $faker->phoneNumber,
            ]);
        }
    }

    public function down()
    {
        Schema::drop('employees');
    }
}

Advertisement

Answer

For Specific File run this command:

php artisan migrate path="database/migrations/Your_Migration_File_Name_table.php"

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement