【问题标题】:how to roll back Laravel command如何回滚 Laravel 命令
【发布时间】:2021-11-09 11:55:48
【问题描述】:

我已经运行了以下 Laravel 命令 PHP artisan make: migration add_category_id_to_posts 但我还需要运行以下命令 PHP artisan make: migration add_category_id_to_posts --table=posts 然后我需要回滚第一个命令并运行第二个命令。那怎么办?

【问题讨论】:

标签: php laravel-5


【解决方案1】:

Fatima Mazhit所说,此命令无法回滚。

只需删除新创建的add_category_id_to_posts 迁移文件并运行php artisan make:migration add_category_id_to_posts --table=posts

【讨论】:

    【解决方案2】:

    转到您的数据库/迁移/您的迁移 删除您最近创建的迁移,然后像这样再次运行命令:

    php artisan make:migration add_category_id_to_posts --table=posts.
    

    注意:如果您使用以下命令迁移迁移,则可以回滚迁移:php artisan migrate 然后您可以通过php artisan migrate:rollback 回滚

    【讨论】:

      【解决方案3】:

      您需要手动删除之前创建的迁移,并在对迁移进行适当更改后再次运行相同的命令。或者直接运行php artisan migrate:rollback,将完成您的任务。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多