【问题标题】:What is the function of create command in migrations?迁移中 create 命令的作用是什么?
【发布时间】:2021-01-07 12:57:15
【问题描述】:

什么是函数(在进行迁移时,例如 php artisan make:migration create_users_table --create=users?? 如果我不使用它会怎样?

【问题讨论】:

  • “功能”是什么意思?
  • laravel.com/docs/master/migrations#generating-migrationsThe --table and --create options may also be used to indicate the name of the table and whether or not the migration will be creating a new table. These options pre-fill the generated migration stub file with the specified table
  • make 命令用于创建文件和添加代码模板进行开发。您可以跳过此步骤并手动创建文件。 php artisan make:migration create_users_table --create=users 此命令将在 database/migrations 目录中创建一个带有预填充代码模板的文件。这只是为了简化开发。
  • 抱歉语法错误。问题应该是:进行迁移时创建的功能是什么,例如在 php artisan make:migration create_users_table --create=users?如果我不使用它会怎样?
  • 我可以在没有 --create 命令的情况下编写 php artisan make:migration create_users_table 吗?

标签: php laravel


【解决方案1】:

create 命令在生成的文件中设置表的名称。 如果迁移的形式是“create__table”,则无需指定表名,因为 laravel 会自动获取 inted 的表名。但是,如果您正在创建迁移以进行更改,例如“ php artisan add_name_column_to_users_table”,如果您不指定 --create 参数,则不会生成蓝图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-31
    • 1970-01-01
    • 2022-06-16
    • 2016-09-05
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 2014-04-27
    相关资源
    最近更新 更多