Merge branch 'master' into Tirokk-Docker-Neo4j-1-1

This commit is contained in:
Robert Schäfer 2019-02-03 13:41:35 +01:00 committed by GitHub
commit 9ab049bbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 132 deletions

46
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at developer@human-connection.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -1,139 +1,34 @@
# Import
# Import of legacy data
For importing Data we need to set some values in the Neo4J config.
This guide helps you to import data from our legacy servers, which are using FeathersJS and MongoDB.
### Neo4J Config
### Prerequisites
You need [docker](https://www.docker.com/) installed on your machine.
Furthermore you need SSH access to the server and you need to know the following login credentials and server settings:
{% hint style="danger" %}
Do not leave this settings on the production environment
{% endhint %}
| Environment variable | Description |
|----------------------|----------------------------------|
| SSH_USERNAME | Your ssh username on the server |
| SSH_HOST | The IP address of the server |
| MONGODB_USERNAME | Mongo username on the server |
| MONGODB_PASSWORD | Mongo password on the server |
| MONGODB_AUTH_DB | Mongo authentication database |
| MONGODB_DATABASE | The name of the mongo database |
| UPLOADS_DIRECTORY | Path to remote uploads folder |
```yaml
dbms.security.procedures.unrestricted=apoc.*
apoc.import.file.enabled=true
### Run the database migration
Run `docker-compose` with all environment variables specified:
```sh
SSH_USERNAME=username SSH_HOST=some.server.com MONGODB_USERNAME='hc-api' MONGODB_PASSWORD='secret' MONGODB_DATABASE=hc_api MONGODB_AUTH_DB=hc_api UPLOADS_DIRECTORY=/var/www/api/uploads docker-compose up
```
### Data import from Mongodumbs
```bash
EXPORT MONGO COLLECTIONS AS mongodump
### Categories
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.categories.json') YIELD value as category
MERGE(c:Category {id: category._id["$oid"]})
ON CREATE SET c.name = category.title,
c.slug = category.slug,
c.icon = category.icon
--
CREATE CONSTRAINT ON (c:Category) ASSERT c.id IS UNIQUE
CREATE CONSTRAINT ON (c:Category) ASSERT c.name IS UNIQUE
CREATE CONSTRAINT ON (c:Category) ASSERT c.slug IS UNIQUE
### Badges
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.badges.json') YIELD value as badge
MERGE(b:Badge {id: badge._id["$oid"]})
ON CREATE SET b.key = badge.key,
b.type = badge.type,
b.icon = badge.image.path,
b.status = badge.status
--
CREATE CONSTRAINT ON (b:Badge) ASSERT b.id IS UNIQUE
CREATE CONSTRAINT ON (b:Badge) ASSERT b.key IS UNIQUE
### Users
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.users.json') YIELD value as user
MERGE(u:User {id: user._id["$oid"]})
ON CREATE SET u.name = user.name,
u.slug = user.slug,
u.email = user.email,
u.password = user.password,
u.avatar = user.avatar,
u.coverImg = user.coverImg,
u.wasInvited = user.wasInvited,
u.role = apoc.text.toUpperCase(user.role)
WITH u, user, user.badgeIds AS badgeIds
UNWIND badgeIds AS badgeId
MATCH (b:Badge {id: badgeId})
MERGE (b)-[:REWARDED]->(u)
--
CREATE INDEX ON :User(name)
CREATE INDEX ON :User(deleted)
CREATE INDEX ON :User(disabled)
CREATE CONSTRAINT ON (u:User) ASSERT u.id IS UNIQUE
CREATE CONSTRAINT ON (u:User) ASSERT u.slug IS UNIQUE
### Contributions
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.contributions.json') YIELD value as post
MERGE (p:Post {id: post._id["$oid"]})
ON CREATE SET p.title = post.title,
p.slug = post.slug,
p.image = post.teaserImg,
p.content = post.content,
p.contentExcerpt = post.contentExcerpt,
p.visibility = apoc.text.toUpperCase(post.visibility),
p.createdAt = datetime(post.createdAt["$date"]),
p.updatedAt = datetime(post.updatedAt["$date"])
WITH p, post, post.tags AS tags, post.categoryIds as categoryIds
UNWIND tags AS tag
UNWIND categoryIds AS categoryId
MATCH (c:Category {id: categoryId}),
(u:User {id: post.userId})
MERGE (t:Tag {id: apoc.create.uuid(), name: tag})
MERGE (p)-[:TAGGED]->(t)
MERGE (u)-[:WROTE]->(p)
MERGE (p)-[:CATEGORIZED]->(c)
--
CREATE INDEX ON :Post(title)
CREATE INDEX ON :Post(content)
CREATE INDEX ON :Post(deleted)
CREATE INDEX ON :Post(disabled)
CREATE CONSTRAINT ON (p:Post) ASSERT p.id IS UNIQUE
CREATE CONSTRAINT ON (p:Post) ASSERT p.slug IS UNIQUE
### Coments
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.comments.json') YIELD value as comment
MERGE (c:Comment {id: comment._id["$oid"]})
ON CREATE SET c.content = comment.content,
c.contentExcerpt = comment.contentExcerpt,
c.deleted = comment.deleted
MATCH (p:Post {id: comment.contributionId}),
(u:User {id: comment.userId})
MERGE (c)-[:COMMENTS]->(p)
MERGE (u)-[:WROTE]->(c)
--
CREATE INDEX ON :Comment(deleted)
CREATE INDEX ON :Comment(disabled)
CREATE CONSTRAINT ON (c:Comment) ASSERT c.id IS UNIQUE
### Follolws
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.follows.json') YIELD value as follow
MATCH (u1:User {id: follow.userId}),
(u2:User {id: follow.foreignId})
MERGE (u1)-[:FOLLOWS]->(u2)
### Shouts
CALL apoc.load.json('file:/Users/Greg/Projekte/HumanConnection/_notes/NEO4J-Import/hc_api.shouts.json') YIELD value as shout
MATCH (u:User {id: shout.userId}),
(p:Post {id: shout.foreignId})
MERGE (u)-[:SHOUTED]->(p)
Download the remote mongo database:
```sh
docker-compose exec db-migration-worker ./import.sh
```
Import the local download into Neo4J:
```sh
docker-compose exec neo4j import/import.sh
```

View File

@ -70,7 +70,7 @@ You can spin up a [hosted Neo4j Sandbox instance](https://neo4j.com/download-cen
Install `neo4j` from the Debian Repository, then [download the APOC plugin](https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.4.0.3/apoc-3.4.0.3-all.jar) to the `/var/lib/neo4j/plugins` directory, e.g. with:
```text
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.4.0.3/apoc-3.4.0.3-all.jar -P /var/lib/neo4j/plugins
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.1/apoc-3.5.0.1-all.jar -P /var/lib/neo4j/plugins
```
{% endtab %}