Skip to content

Instantly share code, notes, and snippets.

@The24thDS
Created June 22, 2021 16:56
Show Gist options
  • Save The24thDS/4871501f8ef9fe85ca9188e389dc68fd to your computer and use it in GitHub Desktop.
Save The24thDS/4871501f8ef9fe85ca9188e389dc68fd to your computer and use it in GitHub Desktop.
Karen Neo4j init script
CREATE CONSTRAINT user_username_unique IF NOT EXISTS ON (n:User) ASSERT n.username IS UNIQUE;
CREATE CONSTRAINT user_email_unique IF NOT EXISTS ON (n:User) ASSERT n.email IS UNIQUE;
CREATE CONSTRAINT user_id_unique IF NOT EXISTS ON (n:User) ASSERT n.id IS UNIQUE;
CREATE CONSTRAINT tag_name_unique IF NOT EXISTS ON (n:Tag) ASSERT n.name IS UNIQUE;
CREATE CONSTRAINT tag_id_unique IF NOT EXISTS ON (n:Tag) ASSERT n.id IS UNIQUE;
CREATE CONSTRAINT model_id_unique IF NOT EXISTS ON (n:Model) ASSERT n.id IS UNIQUE;
CREATE CONSTRAINT collection_id_unique IF NOT EXISTS ON (n:Collection) ASSERT n.id IS UNIQUE;
CREATE CONSTRAINT file_id_unique IF NOT EXISTS ON (n:File) ASSERT n.id IS UNIQUE;
CALL db.index.fulltext.createNodeIndex("modelNamesAndDescriptions", ["Model"], ["name", "description"], {analyzer: "english"});
CREATE INDEX user_id_index IF NOT EXISTS FOR (n:User) ON (n.id);
CREATE INDEX model_id_index IF NOT EXISTS FOR (n:Model) ON (n.id);
CREATE INDEX tag_id_index IF NOT EXISTS FOR (n:Tag) ON (n.id);
CREATE INDEX collection_id_index IF NOT EXISTS FOR (n:Collection) ON (n.id);
CREATE INDEX file_id_index IF NOT EXISTS FOR (n:File) ON (n.id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment