Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
633 stars 199 forks source link

Migration Rollback Error #192

Closed hojabbr closed 4 years ago

hojabbr commented 7 years ago

php artisan neo4j:migrate:rollback

Produces: Undefined index: 2016_10_22_160149_create_users_table

My Migration file looks like this:

<?php

use Vinelab\NeoEloquent\Schema\Blueprint;
use Vinelab\NeoEloquent\Migrations\Migration;

class CreateUsersTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Neo4jSchema::label('User', function (Blueprint $label) {
            $label->unique('id');
            $label->index('name');
            $label->unique('email');
            $label->index('password');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Neo4jSchema::dropIfExists('User');
    }

}

But php artisan neo4j:migrate works correctly.

(Laravel 5.3, NeoEloquent 1.4.2)

heydavid713 commented 7 years ago

Do you have the migration node? How does it look like? Also, how is your folder structure looking?

hojabbr commented 7 years ago

This is my folder structure: screenshot from 2016-10-24 10-20-28

And this is my composer.json: screenshot from 2016-10-24 10-21-03

And I believe these are my nodes: screenshot from 2016-10-24 10-22-35

heydavid713 commented 7 years ago

You might want to delete the users_table migration from the folder. Also remove that node from the DB and there should be no problem.

Remcojansen88 commented 7 years ago

Same problem here, the problem is in the call of the default rollback

Vinelab\NeoEloquent\Console\Migrations\MigrateRollbackCommand $this->migrator->rollback($pretend);

The rollback of elequent has this parameters public function rollback($paths = [], array $options = []);

javiertoledos commented 7 years ago

Same problem here, the migration is done successfully and you can see the NeoEloquentMigration nodes in the Neo4j database, however, when you try to roll back, you get the "undefined index" error.

I did a test by hardcoding the path in $this->migrator->rollback(['database/labels']); in src/Vinelab/NeoEloquent/Console/Migrations/MigrateRollbackCommand.php:56 and the rollback ran successfully

Anahkiasen commented 7 years ago

Same issue here. I can confirm @javiertoledos's fix works though in the meantime

tumainimosha commented 6 years ago

I am facing similar issue when calling rollback. Migrate works fine, but rollback throws below trace

./artisan neo4j:migrate:rollback

   Vinelab\NeoEloquent\QueryException  : ParameterNotFoundException: Expected parameter(s): migration, migration

  at /path-to-project/vendor/vinelab/neoeloquent/src/Connection.php: 467

Exception trace:

1   Vinelab\NeoEloquent\Connection::run("MATCH (neoEloquentMigration:`NeoEloquentMigration`) WHERE neoEloquentMigration.migration = {migration} OPTIONAL MATCH (neoEloquentMigration:`NeoEloquentMigration`)-[r]-()  WHERE neoEloquentMigration.migration = {migration} DELETE  neoEloquentMigration,r", Object(Closure))
      /path-to-project/vendor/vinelab/neoeloquent/src/Connection.php : 222
2   Vinelab\NeoEloquent\Connection::affectingStatement("MATCH (neoEloquentMigration:`NeoEloquentMigration`) WHERE neoEloquentMigration.migration = {migration} OPTIONAL MATCH (neoEloquentMigration:`NeoEloquentMigration`)-[r]-()  WHERE neoEloquentMigration.migration = {migration} DELETE  neoEloquentMigration,r")
      /path-to-project/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 435

I have tried @javiertoledos fix , but I am yet to get it working.

(Laravel 5.6, NeoEloquent 1.4.6)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.