在laravel中迁移特定的表

时间:2016-03-05 13:02:44

标签: php laravel cmd command artisan

使用命令php artisan migrate迁移所有表。但我有员工表,我与其他表一起迁移。但它没有迁移(我在phpmyadmin中看不到它)。现在,当我再次使用php artisan migrate命令时,它不会显示任何要迁移的内容。如何迁移特定员工表?

<?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');
    }
}

0 个答案:

没有答案