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?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Datadimension
  • 872
  • 1
  • 12
  • 31
  • Laravel already provides the correct migration in https://github.com/laravel/laravel/tree/master/database/migrations you probably overwrote it – apokryfos Jan 01 '20 at 22:08
  • The problem was it seemed to create the correct migrations once and then just the basic 3 columns – Datadimension Jan 02 '20 at 17:24

1 Answers1

4

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

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • 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 – Datadimension Jan 02 '20 at 17:26