php artisan migrate如何执行指定文件

migrations文件夹下有三个文件,前面两个文件都已经迁移成功,现在我想迁移第三个,每次都是迁移第二个表,然后报错表已经存在。回滚的时候每次都是回滚第一个文件。有没有什么方法可以指定php artisan migrate的执行文件。

阅读 11.6k
4 个回答

执行:php artisan migrate --help

会出现:

Options:
      --database[=DATABASE]  The database connection to use.
      --force                Force the operation to run when in production.
      --path[=PATH]          The path of migrations files to be executed.
      --pretend              Dump the SQL queries that would be run.
      --seed                 Indicates if the seed task should be re-run.
      --step                 Force the migrations to be run so they can be rolled back individually.
  -h, --help                 Display this help message
  -q, --quiet                Do not output any message
  -V, --version              Display this application version
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
      --env[=ENV]            The environment the command should run under
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

看到 --path=xxx 这个选项吗?就是你想要得咯

指定 需要执行的那个文件的时间戳试试

指定文件是可以的,php artisan migrate --path=xxx

把记录迁移的信息的那张表truncate下

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题