Description
Original bug found here: https://github.com/illuminate/database/issues/111 - Moved to his repo as per Taylor. Here's the original text:
I spoke with Machuga in IRC - It was suggested I create an issue.
Issue:
Error after first migration: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'up_migrations' already exists
Steps to reproduce:
- Fresh install of L4
- Add a prefix to database in database connection config (MySql)
- Create a migration
$ php artisan migrate:make create_users_table --table=users --create
- Fill in some fields, run the migration
$ php artisan migrate
- Attempt a migrate:refresh
$ php artisan migrate:refresh
- ERROR:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'up_migrations' already exists
Relevant files:
I tracked this down to this file: Illuminate\Database\MigrationsDatabaseMigrationRepository::repositoryExists()
and specifically within that, the call to return $schema->hasTable($this->table);
here
The $this->table variable passed to hasTable() does not include the table prefix. Illuminate\Database\Schema\MySqlBuilder::hasTable($table)
does not check for prefix either.
Unfortunately I'm not yet familiar with the code/convention to know where you'd prefer to look up the prefix. (Not sure what class should have that "knowledge")