activegraph icon indicating copy to clipboard operation
activegraph copied to clipboard

After migration, saving to the database throws Neo4j::Driver::Exceptions::DatabaseException

Open wlaoman opened this issue 3 years ago • 1 comments

Hello, I am not a very experienced programmer trying to use Neo4j with Rails and really enjoying it this far. However, I’m having two problems with migrating:

Generated migrations for namespaces models doesn't work properly

The first problem is just annoying - when generating a new namespaces model, in the migration generated by the ActiveGraph generator the object name is not quoted in the symbol, causing the rake task to fail.

For example, rails generate model Documentations::DocuRev Creates the following entry in the migrations file:

  def up
    add_constraint :Documentations::DocuRev, :uuid
  end

Resulting in the following error when migrating

== 20210310115300 CreateDocumentation: running... ==============================
 CYPHER CREATE CONSTRAINT ON (n:`Documentation`) ASSERT n.`uuid` IS UNIQUE 
== 20210310115300 CreateDocumentation: migrated (0.1462s) ======================

== 20210310132055 CreateDocuRev: running... ====================================
rake aborted!
TypeError: :Documentations is not a class/module

The workaround is easy, just quote the object name:

  def up
    add_constraint :”Documentations::DocuRev,” :uuid
  end

After migration, nothing can be saved to the database

The second problem is worse. After successfully migrating the database, trying to save something in the database results in the following error:

> r1 = Documentations::DocuRev.new
=> #<Documentations::DocuRev uuid: nil, label: nil>
> r1.save
Traceback (most recent call last):
        1: from (irb):6:in `<main>'
Neo4j::Driver::Exceptions::DatabaseException (OnlineIndexProxy[accessor:org.neo4j.kernel.impl.index.schema.GenericNativeIndexAccessor@5a11ac0a, descriptor:Index( 8, 'constraint_ba6ec952', UNIQUE BTREE, :label[6](property[23]), native-btree-1.0 )] is ONLINE)

I managed to get around the problem by manually deleting and recreating all the constraints using the Neo4j Web Interface:

CALL db.constraints
=> <list of all constraints with name and description>
DROP CONSTRAINT <constraint name>
CREATE <constraint description>

Runtime information:

Neo4j database version: 4.0.11 active-graph gem version: 10.0.2 neo4j-ruby-driver gem version: 1.7.4 Using Michael Simons seabolt driver (brew install michael-simons/homebrew-seabolt/seabolt)

wlaoman avatar Mar 11 '21 16:03 wlaoman

Looks like migrations with namespaces are messed up. Thanks for reporting @wlaoman. We will take a look into this.

amitsuryavanshi avatar Mar 11 '21 16:03 amitsuryavanshi