Php 在laravel中迁移特定表
使用命令Php 在laravel中迁移特定表,php,laravel,cmd,command,laravel-artisan,Php,Laravel,Cmd,Command,Laravel Artisan,使用命令php artisan migrate迁移所有表。但我有一个employees表,我和其他表一起迁移了它。但是它没有被迁移(我在phpmyadmin中看不到它)。现在,当我再次使用phpartisanmigrate命令时,它不会显示任何要迁移的内容。如何迁移特定的employees表 <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; clas
php artisan migrate
迁移所有表。但我有一个employees表,我和其他表一起迁移了它。但是它没有被迁移(我在phpmyadmin中看不到它)。现在,当我再次使用phpartisanmigrate
命令时,它不会显示任何要迁移的内容。如何迁移特定的employees表
<?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');
}
}
运行php artisan migrate
时是否出现任何错误?另外,您不应该在迁移中看到数据库,这就是它的用途。没有任何错误。它不显示任何要迁移的内容。@BogdanThen它可能意味着employees表迁移之前已迁移。您以前运行过迁移吗。如果你这么做了,你需要把它滚回去。您可以检查数据库中的migrations
表,查看是否可以找到迁移文件名。如果它在最后一批中,那么您可以使用php artisan migrate:rollback
撤消这些更改并再次尝试运行它。尝试php artisan migrate:refresh,然后查看该表是否已迁移。另一方面,根据我的猜测,没有办法迁移单个表。