【发布时间】:2018-02-18 23:58:02
【问题描述】:
我在 neo4j 中更改了一条记录的名称。现在,我收到一个提示正在等待迁移的错误。
class CreateOrganization < Neo4j::Migrations::Base
def up
execute("MATCH (n:Institution) SET n:Organization REMOVE n:Institution RETURN n")
end
def down
execute("MATCH (n:Organization) SET n:Institution REMOVE n:Organization RETURN n")
end
end
导轨 5.1.4
neo4j 3.3.2
当我与CALL db.constraints 核对时,我可以看到他们仍然指向机构。目标是让他们指向组织。
"CONSTRAINT ON ( institution:Institution ) ASSERT institution.uuid IS UNIQUE"
错误看起来像这样......
Neo4j::DeprecatedSchemaDefinitionError in SessionsController#new
Some schema elements were defined by the model (which is no longer
supported), but they do not exist in the database. Run the following to
create them if you haven't already: rake
neo4j:generate_schema_migration[constraint,Organization,uuid] rake
neo4j:generate_schema_migration[index,Organization,sector] And then run
`rake neo4j:migrate` (zshell users may need to escape the brackets)
当我跑步时
rake neo4j:generate_schema_migration[constraint,Organization,uuid]
我明白了
zsh: no matches found: neo4j:generate_schema_migration[constraint,Organization,uuid]
更新:在我创建了 Brian 在他的回答中提供的迁移之后,与约束相关的错误部分消失了。但是,与索引相关的部分错误仍然存在。我尝试使用帮助器从模型中添加和删除索引。
class AddIndexToOrganization < Neo4j::Migrations::Base
def up
add_index :Organization, :uuid
drop_index :Institution, :uuid
end
def down
drop_index :Organization, :uuid
add_index :Institution, :uuid
end
end
然后我尝试运行迁移。这会抛出错误:
== 20180224004338 AddIndexToOrganization: running...
===========================
rake aborted!
Neo4j::MigrationError: Duplicate index for Organization#uuid
有趣的是,当我使用 CALL db.indexes 时,我找不到关于组织的索引,而这仍然是 "INDEX ON :Institution(sector)" "Institution"
【问题讨论】: