0

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?

2
  • Laravel already provides the correct migration in github.com/laravel/laravel/tree/master/database/migrations you probably overwrote it Commented Jan 1, 2020 at 22:08
  • The problem was it seemed to create the correct migrations once and then just the basic 3 columns Commented Jan 2, 2020 at 17:24

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this is unexpected behaviour for me, would have thought it would create any REQUIRED columns in a table. I did indeed delete them due to a Class already defined error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.