我正试图为我的spring实体生成Index和Constraint。我并没有使用任何spring数据的功能来实现它,比如indexes.auto=assert。
如何生成具有以下条件的脚本
offline模式下生成脚本。我不能提供任何Neo4j服务器,用户,密码等。我使用的maven依赖项是
<!-- https://mvnrepository.com/artifact/org.liquigraph/liquigraph-core -->
<dependency>
<groupId>org.liquigraph</groupId>
<artifactId>liquigraph-core</artifactId>
<version>3.1.0</version>
</dependency>CREATE CONSTRAINT ON ( action:Action ) ASSERT action.id IS UNIQUE我该怎么做?
发布于 2019-05-22 13:12:46
如果您要从Java运行您的变更集,您不需要将任何凭据放入其中,只需使用CYPHER查询即可。
创建changelog.xml并放入资源。
<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.liquigraph.org/schema/1.0/liquigraph.xsd">
<changeset id="action-contraint" author="JITHIN">
<query>CREATE CONSTRAINT ON (action:Action) ASSERT action.id IS UNIQUE</query>
</changeset>
</changelog>然后可以从运行迁移,以及您可以在应用程序中保存的所有凭据。
Configuration configuration = new ConfigurationBuilder()
.withMasterChangelogLocation("changelog.xml")
.withUri("jdbc:neo4j:http://localhost:7474")
.withUsername(user)
.withPassword(pass)
.withRunMode()
.build();
Liquigraph liquigraph = new Liquigraph();
liquigraph.runMigrations(configuration);执行后,应该添加约束,至少对我适用。
╒══════════════════════════════════════════════════════════════════════╕
│"description" │
╞══════════════════════════════════════════════════════════════════════╡
│"CONSTRAINT ON ( __liquigraphlock:__LiquigraphLock ) ASSERT __liquigra│
│phlock.name IS UNIQUE" │
├──────────────────────────────────────────────────────────────────────┤
│"CONSTRAINT ON ( action:Action ) ASSERT action.id IS UNIQUE" │
└──────────────────────────────────────────────────────────────────────┘https://stackoverflow.com/questions/56254443
复制相似问题