Laravel 在生产服务器上迁移

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46697769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:47:43  来源:igfitidea点击:

Laravel migrate on production server

laravelartisanmigrate

提问by Stefano Giacone

I'm using Laravel and as part of my deploy routine I have the command

我正在使用 Laravel,作为我的部署例程的一部分,我有命令

RUN php artisan migrate

RUN php artisan migrate

Since I'm in production, I get the error

由于我在生产中,我收到错误

Application in production, Command Cancelled!

生产中的应用程序,命令已取消!

The fix is easy: RUN php rankbot/artisan migrate --forcebut I feel this is not the right way to do it? What's the best way to ensure the DB schema is always up to date?

解决方法很简单:RUN php rankbot/artisan migrate --force但我觉得这不是正确的方法?确保数据库架构始终保持最新的最佳方法是什么?

回答by Unamata Sanatarai

This is the right way to go about it.

这是正确的方法。

When you run a migration on production, you best be sure what it's going to do to your database, as some actions might not be rollbackable.

在生产中运行迁移时,最好确定它将对数据库执行什么操作,因为某些操作可能无法回滚。

The confirmation promptis there to make you stop and think twice before potentially cause harm.

确认提示会出现让你停下来三思而后可能造成伤害。

Some migration operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the --force flag

https://laravel.com/docs/5.5/migrations#running-migrations

某些迁移操作具有破坏性,这意味着它们可能会导致您丢失数据。为了防止您对生产数据库运行这些命令,在执行这些命令之前,系统会提示您进行确认。要强制命令在没有提示的情况下运行,请使用 --force 标志

https://laravel.com/docs/5.5/migrations#running-migrations