user3077503
user3077503

Reputation:

laravel php artisan migrate does not create a new table

I have created a user migration and then created the table. Here is the command:

php artisan migration:make create_users_table --table=users --create

And then I updated the schema for my desired fields, and ran this command:

php artisan migration

And it works and created the table with all of its field.

Then I again typed the following command to create a new table's schema for comments table"

php artisan migration:make create_comments_table --table=comments --create

And it worked.

And I updated the actual schema of the table, but then when I commanded php artisan migrate it throws an error:

Base table or view already exists. table 'users' ....

Why? because I'm creating the comments table, what it has to do with users table.

Upvotes: 3

Views: 6036

Answers (2)

arcsum
arcsum

Reputation: 156

To avoid problems, try creating the tables like these

php artisan migrate:make create_users_table --table=users --create=users

php artisan migrate:make create_comments_table --table=comments --create=comments

taking note of the arguments in --create for each cli command.

Upvotes: 2

JohnTaa
JohnTaa

Reputation: 2824

php artisan migrate:make create_comments_table --table=comments --create

The --table and --create options may also be used to indicate the name of the table, and whether the migration will be creating a new table

migrations

Upvotes: 1

Related Questions