Artisan, creating tables in database

后端 未结 3 1609
不思量自难忘°
不思量自难忘° 2021-02-02 07:17

I am trying to create mysql tables in Laravel 5. I created a file in /project/database/migrations called users.php:

[...]
public functi         


        
相关标签:
3条回答
  • 2021-02-02 07:30

    in laravel 5 first we need to create migration and then run the migration

    Step 1.

    php artisan make:migration create_users_table --create=users
    

    Step 2.

    php artisan migrate
    
    0 讨论(0)
  • 2021-02-02 07:38

    Migration files must match the pattern *_*.php, or else they won't be found. Since users.php does not match this pattern (it has no underscore), this file will not be found by the migrator.

    Ideally, you should be creating your migration files using artisan:

    php artisan make:migration create_users_table
    

    This will create the file with the appropriate name, which you can then edit to flesh out your migration. The name will also include the timestamp, to help the migrator determine the order of migrations.

    You can also use the --create or --table switches to add a little bit more boilerplate to help get you started:

    php artisan make:migration create_users_table --create=users
    

    The documentation on migrations can be found here.

    0 讨论(0)
  • 2021-02-02 07:48

    In order to give a value in the table, we need to give a command:

    php artisan make:migration create_users_table
    

    and after then this command line

    php artisan migrate
    

    ......

    0 讨论(0)
提交回复
热议问题