Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wlaoman opened this issue Mar 11, 2021 · 1 comment
Labels

Comments

@wlaoman
Copy link

wlaoman commented Mar 11, 2021

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)

@amitsuryavanshi
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants