-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdefine_schema.sh
26 lines (20 loc) · 1.02 KB
/
define_schema.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
docker pull neo4j:4.4.2
docker compose up -d neo4j
# Wait till neo4j is available
sleep 60
# Load environment variables from .env file
if [ -f .env ]; then
source .env
else
echo ".env file not found"
exit 1
fi
docker cp conf/disabled.conf neo4j:/var/lib/neo4j/conf/neo4j.conf
docker exec -e NEO4J_USERNAME="$NEO4J_USERNAME" -e NEO4J_PASSWORD="$NEO4J_PASS" neo4j cypher-shell -u "$NEO4J_USERNAME" -p "$NEO4J_PASS" "ALTER USER $NEO4J_USERNAME SET PASSWORD '$NEO4J_PASS';"
docker cp conf/neo4j.conf neo4j:/var/lib/neo4j/conf/neo4j.conf
docker exec neo4j neo4j restart
# Define unique constraints
docker exec neo4j cypher-shell -u $NEO4J_USERNAME -p $NEO4J_PASS -d neo4j 'CREATE CONSTRAINT IF NOT EXISTS ON (t:Transaction) ASSERT t.hash IS UNIQUE;'
docker exec neo4j cypher-shell -u $NEO4J_USERNAME -p $NEO4J_PASS -d neo4j 'CREATE CONSTRAINT IF NOT EXISTS ON (a:Address) ASSERT a.id IS UNIQUE;'
docker exec neo4j cypher-shell -u $NEO4J_USERNAME -p $NEO4J_PASS -d neo4j 'CREATE INDEX FOR (t:Transaction) ON (t.timestamp);'
docker compose stop