Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.33k stars 586 forks source link

Tests trying to create a table twice #29

Closed joboscribe closed 7 years ago

joboscribe commented 10 years ago

We have the following migration and when we run tests they fail because

PDOException: SQLSTATE[HY000]: General error: 1 there is already a table named block

Here's the migration:

        public function up()
        {
            Schema::create('block', function(Blueprint $table)
            {
                $table->increments('block_id');
                    $table->string('field')->default('')->index('field');
                $table->string('operator', 6)->default('')->index('operator');
                $table->string('block')->default('')->index('block');
                $table->integer('weight')->unsigned()->nullable()->default(1)->index('weight');
                $table->string('added_by', 16)->nullable();
                $table->timestamp('ts')->default(DB::raw('CURRENT_TIMESTAMP'));
            });
        }

I removed the index->() calls and the error went away.

Let me know what other info i can provide that might be of help.

Xethron commented 7 years ago

This seems to be related to #94, index names need to be unique across the entire DB in SQLite. Simply remove the index name to let Laravel create a unique name for you. Hope that helps :)