Datadimension
Datadimension

Reputation: 1045

Laravel default user migration

I am trying to use Laravel to set up the required database tables. Using the documented:

php artisan make:migration create_users_table;
php artisan migrate;

However, this generates a simple three-column table:

id
created_at
updated_at

Authentication (default Laravel setup) requires obvious fields such as email and password, meaning an error when trying to use 'out of the box' authentication:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: select count(*) as aggregate from users where email =

I am missing something here, I would have thought that to use the preset authentication scaffolding, Laravel would set up the database correctly.

What should I be running to do this from the outset?

Upvotes: 0

Views: 7582

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111869

In fact you don't need to create this migration. By default in fresh Laravel installation you have created user migrations so you can just run

php artisan migrate 

to run this migration.

Default users migration is here and all 3 default migrations can be found here.

And in case you create custom new migration then it contains just id and timestamps (created_at/updated_at) so you should edit such migration file to put columns you want

Upvotes: 4

Related Questions