【发布时间】:2021-07-01 10:31:24
【问题描述】:
我正在Laravel Framework 8.33.1 上进行开发,并在我的本地环境和生产环境中进行了以下迁移。
class CreateCompanyTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('company', function (Blueprint $table) {
$table->id();
$table->integer('company_id');
$table->integer('messageId');
$table->string('url');
$table->timestamps();
/**
New table:
$table->id();
$table->integer('company_id')->nullable($value = true);
$table->integer('messageId');
$table->integer('people_id')->nullable($value = true);
$table->string('url')->nullable($value = true);
$table->timestamps();
*/
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('company');
}
}
我想使用以下适应字段更改迁移:
$table->id();
$table->integer('company_id')->nullable($value = true);
$table->integer('messageId');
$table->integer('people_id')->nullable($value = true);
$table->string('url')->nullable($value = true);
$table->timestamps();
由于我在生产中使用当前迁移,我不想丢失数据。
我只是尝试使用我的新表定义修改迁移文件,但我得到:
> php artisan migrate
Nothing to migrate.
关于如何在 laravel 中正确更改迁移有什么建议吗?
感谢您的回复!
【问题讨论】:
-
如果 company 表被删除了,可以吗?
-
stackoverflow.com/questions/16791613/… 这几乎有你需要的一切。