Framework: Migration doesn't account for prefix when checking if migration table exists [bug]

Created on 11 Jan 2013  ·  3Comments  ·  Source: laravel/framework

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:

  1. Fresh install of L4
  2. Add a prefix to database in database connection config (MySql)
  3. Create a migration $ php artisan migrate:make create_users_table --table=users --create
  4. Fill in some fields, run the migration $ php artisan migrate
  5. Attempt a migrate:refresh $ php artisan migrate:refresh
  6. 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")

bug

All 3 comments

OK, Thanks. We'll get it fixed.

Fixed.

I´m having this very same issue and I just downloaded the framework from the site.
I wonder if the fix was commited to the site version.

Was this page helpful?
0 / 5 - 0 ratings