作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在命令行上运行了php artisan migrate:rollback
,因此迁移删除了数据库中的所有表。
仅创建了一个迁移,但已使用的数据库中有其他表。
laravel documentation说:
To drop an existing table, you may use the
drop
ordropIfExists
methods.
迁移代码中的函数 down()
是默认的,如下所示:
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('image')->unsigned()->nullable();
$table->string('name', 64);
$table->string('slug', 64)->unique();
$table->integer('price')->unsigned();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
我认为 Schema::dropIfExists('products')
在这种情况下无法正常工作,这是一个错误吗?或者我的(和 laravel 文档)错误?
最佳答案
关于php - Schema::dropIfExists() 在迁移时删除了数据库中的所有表:回滚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56367482/
我在命令行上运行了php artisan migrate:rollback,因此迁移删除了数据库中的所有表。 仅创建了一个迁移,但已使用的数据库中有其他表。 laravel documentation
我是一名优秀的程序员,十分优秀!