安全删除Laravel中的迁移 [英] Safely remove migration In Laravel
问题描述
在Laravel中,似乎有一个用于创建迁移但不能删除的命令.
In Laravel, there appears to be a command for creating a migration, but not removing.
创建迁移命令:
php artisan migrate:make create_users_table
如果要删除迁移,是否可以安全地删除database/migrations文件夹中的相应迁移文件?
If I want to delete the migration, can I just safely delete the corresponding migrations file within the database/migrations folder?
迁移文件:
2013_05_31_220658_create_users_table
推荐答案
我不小心创建了一个名字错误的迁移文件(命令: php artisan migrate:make
).我没有运行( php artisan migrate
)迁移,所以我决定将其删除.
我的步骤:
I accidentally created a migration with a bad name (command: php artisan migrate:make
). I did not run (php artisan migrate
) the migration, so I decided to remove it.
My steps:
- 手动删除
app/database/migrations/my_migration_file_name.php
下的迁移文件
- 重置作曲家的自动加载文件:
composer dump-autoload
- 放松
- Manually delete the migration file under
app/database/migrations/my_migration_file_name.php
- Reset the composer autoload files:
composer dump-autoload
- Relax
如果您确实运行了迁移( php artisan migrate
),则可以执行以下操作:
If you did run the migration (php artisan migrate
), you may do this:
a)-运行撤消上一次迁移的正确方法(Thnx @Jakobud)
a) Run migrate:rollback
- it is the right way to undo the last migration (Thnx @Jakobud)
b)如果migrate:rollback
不起作用,请手动执行(我记得以前版本中的migration:rollback的错误):
b) If migrate:rollback
does not work, do it manually (I remember bugs with migrate:rollback in previous versions):
- 手动删除
app/database/migrations/my_migration_file_name.php
下的迁移文件
- 重置作曲家的自动加载文件:
composer dump-autoload
- 修改数据库:从 migrations 表中删除最后一个条目
- Manually delete the migration file under
app/database/migrations/my_migration_file_name.php
- Reset the composer autoload files:
composer dump-autoload
- Modify your database: Remove the last entry from the migrations table
这篇关于安全删除Laravel中的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!