Change README.md

This commit is contained in:
elweyn 2023-02-28 13:05:13 +01:00
parent a3ac360889
commit fb353b8a68
4 changed files with 15 additions and 14 deletions

View File

@ -190,7 +190,7 @@ For Docker compose `up` or `build` commands, you can use our Apple M1 override f
# for development # for development
$ docker compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.apple-m1.override.yml up $ docker compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.apple-m1.override.yml up
# only once: init admin user and create indexes and contraints in Neo4j database # only once: init admin user and create indices and constraints in Neo4j database
$ docker compose exec backend yarn prod:migrate init $ docker compose exec backend yarn prod:migrate init
# clean db # clean db
$ docker compose exec backend yarn db:reset $ docker compose exec backend yarn db:reset
@ -199,7 +199,7 @@ $ docker compose exec backend yarn db:seed
# for production # for production
$ docker compose -f docker-compose.yml -f docker-compose.apple-m1.override.yml up $ docker compose -f docker-compose.yml -f docker-compose.apple-m1.override.yml up
# only once: init admin user and create indexes and contraints in Neo4j database # only once: init admin user and create indices and constraints in Neo4j database
$ docker compose exec backend /bin/sh -c "yarn prod:migrate init" $ docker compose exec backend /bin/sh -c "yarn prod:migrate init"
``` ```

View File

@ -139,6 +139,7 @@ Prepare database once before you start by running the following command in a sec
```bash ```bash
# in main folder while docker-compose is up # in main folder while docker-compose is up
$ docker-compose exec backend yarn run db:migrate init $ docker-compose exec backend yarn run db:migrate init
$ docker-compose exec backend yarn run db:migrate up
``` ```
Then clear and seed database by running the following command as well in the second terminal: Then clear and seed database by running the following command as well in the second terminal:

View File

@ -24,7 +24,7 @@ $ docker compose -f docker-compose.yml -f docker-compose.apple-m1.override.yml u
# for production testing Docker images from DockerHub # for production testing Docker images from DockerHub
$ docker compose -f docker-compose.ocelotsocial-branded.yml -f docker-compose.apple-m1.override.yml up $ docker compose -f docker-compose.ocelotsocial-branded.yml -f docker-compose.apple-m1.override.yml up
# only once: init admin user and create indexes and contraints in Neo4j database # only once: init admin user and create indices and constraints in Neo4j database
$ docker compose exec backend /bin/sh -c "yarn prod:migrate init" $ docker compose exec backend /bin/sh -c "yarn prod:migrate init"
``` ```

View File

@ -55,15 +55,15 @@ Start Neo4J and confirm the database is running at [http://localhost:7474](http:
Here we describe some rarely used Cypher commands for Neo4j that are needed from time to time: Here we describe some rarely used Cypher commands for Neo4j that are needed from time to time:
### Index And Contraint Commands ### Index And Constraint Commands
If indexes or constraints are missing or not set correctly, the browser search will not work or the database seed for development will not work. If indices or constraints are missing or not set correctly, the browser search will not work or the database seed for development will not work.
The indexes and constraints of our database are set in `backend/src/db/migrate/store.js`. The indices and constraints of our database are set in `backend/src/db/migrate/store.js`.
This is where the magic happens. This is where the magic happens.
It's called by our `prod:migrate init` command. It's called by our `prod:migrate init` command.
This command initializes the Admin user and creates all necessary indexes and constraints in the Neo4j database. This command initializes the Admin user and creates all necessary indices and constraints in the Neo4j database.
***Calls in development*** ***Calls in development***
@ -98,27 +98,27 @@ On a server with Kubernetes cluster:
$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate init" $ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate init"
``` ```
***Cypher commands to show indexes and constraints*** ***Cypher commands to show indices and constraints***
```bash ```bash
# in browser command line or cypher shell # in browser command line or cypher shell
# show all indexes and constraints # show all indices and constraints
$ :schema $ :schema
# show all indexes # show all indices
$ CALL db.indexes(); $ CALL db.indexes();
# show all constraints # show all constraints
$ CALL db.constraints(); $ CALL db.constraints();
``` ```
***Cypher commands to create and drop indexes and constraints*** ***Cypher commands to create and drop indices and constraints***
```bash ```bash
# in browser command line or cypher shell # in browser command line or cypher shell
# create indexes # create indices
$ CALL db.index.fulltext.createNodeIndex("post_fulltext_search",["Post"],["title", "content"]); $ CALL db.index.fulltext.createNodeIndex("post_fulltext_search",["Post"],["title", "content"]);
$ CALL db.index.fulltext.createNodeIndex("user_fulltext_search",["User"],["name", "slug"]); $ CALL db.index.fulltext.createNodeIndex("user_fulltext_search",["User"],["name", "slug"]);
$ CALL db.index.fulltext.createNodeIndex("tag_fulltext_search",["Tag"],["id"]); $ CALL db.index.fulltext.createNodeIndex("tag_fulltext_search",["Tag"],["id"]);
@ -126,6 +126,6 @@ $ CALL db.index.fulltext.createNodeIndex("tag_fulltext_search",["Tag"],["id"]);
# drop an index # drop an index
$ DROP CONSTRAINT ON ( image:Image ) ASSERT image.url IS UNIQUE $ DROP CONSTRAINT ON ( image:Image ) ASSERT image.url IS UNIQUE
# drop all indexes and constraints # drop all indices and constraints
$ CALL apoc.schema.assert({},{},true) YIELD label, key RETURN * ; $ CALL apoc.schema.assert({},{},true) YIELD label, key RETURN * ;
``` ```