From 9478bf098849af49a0068beae96db26b010d16ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 21 Jan 2019 16:16:05 +0100 Subject: [PATCH 1/4] Provide documentation for `db-migration-worker` @appinteractive ping This is basically the documentation of the PR description: https://github.com/Human-Connection/Nitro-Backend/pull/115 --- backend/data-import.md | 156 +++++++---------------------------------- 1 file changed, 25 insertions(+), 131 deletions(-) diff --git a/backend/data-import.md b/backend/data-import.md index 7923740eb..fe466baad 100644 --- a/backend/data-import.md +++ b/backend/data-import.md @@ -1,139 +1,33 @@ -# 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 | -```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 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 +``` From 01f9a5521060d68dde7726bca48ef1abf3e217ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Tue, 22 Jan 2019 12:53:01 +0100 Subject: [PATCH 2/4] Update to the latest changes on the backend for reference: https://github.com/Human-Connection/Nitro-Backend/pull/127 --- backend/data-import.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/data-import.md b/backend/data-import.md index fe466baad..d08b89129 100644 --- a/backend/data-import.md +++ b/backend/data-import.md @@ -14,12 +14,13 @@ Furthermore you need SSH access to the server and you need to know the following | 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 | ### 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 docker-compose up +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 ``` Download the remote mongo database: From be993c8a9049254946ce9265bbb3885c515384f9 Mon Sep 17 00:00:00 2001 From: Armin Date: Sun, 27 Jan 2019 23:21:52 +0100 Subject: [PATCH 3/4] Update APOC plugin version --- backend/installation/configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/installation/configuration.md b/backend/installation/configuration.md index 54bab4747..82d048f5a 100644 --- a/backend/installation/configuration.md +++ b/backend/installation/configuration.md @@ -22,9 +22,9 @@ Note that grand-stack-starter does not currently bundle a distribution of Neo4j. **Install APOC plugin on Debian-based systems** -When you have 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 manually or with: +When you have install Neo4j from the Debian Repository, then download the [APOC plugin](https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.1/apoc-3.5.0.1-all.jar) to the `/var/lib/neo4j/plugins` directory manually or 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 ``` From 0bffad734a0cc475fbd22fba70d266fceb020b2a Mon Sep 17 00:00:00 2001 From: Sam Joseph Date: Mon, 28 Jan 2019 17:29:48 +0000 Subject: [PATCH 4/4] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..19f3854c1 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -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/