2

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 Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

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 = Faker\Factory::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');
    }
}
micky
  • 277
  • 1
  • 13
  • 39
  • Are you getting any errors when running `php artisan migrate`? And as a side note you shouldn't be seeing the database inside a migration, that's what [Seeder Classes](https://laravel.com/docs/5.2/seeding) are for. – Bogdan Mar 05 '16 at 13:10
  • no nothing errors. It displays nothing to migrate.@Bogdan – micky Mar 05 '16 at 13:11
  • Then it probably means the employees table migration was migrated before. Did you run that migration before. If you did you need to roll it back. You can check the `migrations` table your database to see if you can find the migration filename. If it's in the last batch, then you can use `php artisan migrate:rollback` to undo those changes and try running it again. – Bogdan Mar 05 '16 at 13:17
  • Try php artisan migrate:refresh and then see if that table is migrated or not. Other wise there is no way to migrate the single table as per my guess. – Siddharth Mar 05 '16 at 13:21
  • Check out this [answer](https://stackoverflow.com/a/45476287/10544835) worked for me. – jafi kay Nov 13 '19 at 18:01

2 Answers2

2

Don't forget to add: --path

E.g

php artisan migrate --path="database/migrations/2025_07_16_145318_create_expression_of_interests_table.php"
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
GeorgeKN
  • 71
  • 5
0

For Specific File run this command:

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

Tuhin
  • 332
  • 3
  • 7