Reverted a couple changes by @mattwr18

We have to figure out if `mergeRels: true` is actually avoiding
duplicate relationships 🤔.

Before:
(l1)-[:IS_IN]->(l2)
(l1)-[:IS_IN]->(l3)

After:
(l1)-[:IS_IN]->(new)
(l1)-[:IS_IN]->(new)
This commit is contained in:
roschaefer 2020-01-23 17:38:31 +01:00
parent 28dae1f854
commit e343701057
4 changed files with 11 additions and 9 deletions

View File

@ -120,7 +120,7 @@ you have to migrate your data e.g. because your data modeling has changed.
{% tab title="Docker" %}
Generate a data migration file:
```bash
$ docker-compose exec backend yarn run db:migrate:create your_data_migration --date-format 'yyyymmddHHmmss' --template-file src/db/migrate/template.js
$ docker-compose exec backend yarn run db:migrate:create your_data_migration
# Edit the file in ./src/db/migrations/
```
@ -132,7 +132,7 @@ $ docker-compose exec backend yarn run db:migrate up
{% tab title="Without Docker" %}
Generate a data migration file:
```bash
$ yarn run db:migrate:create your_data_migration --date-format 'yyyymmddHHmmss' --template-file src/db/migrate/template.js
$ yarn run db:migrate:create your_data_migration
# Edit the file in ./src/db/migrations/
```

View File

@ -16,7 +16,7 @@
"db:reset": "yarn run db:clean",
"db:seed": "babel-node src/db/seed.js",
"db:migrate": "yarn run __migrate --store ./src/db/migrate/store.js",
"db:migrate:create": "yarn run __migrate --template-file ./src/db/migrate/template.js create"
"db:migrate:create": "yarn run __migrate --template-file ./src/db/migrate/template.js --date-format 'yyyymmddHHmmss' create"
},
"author": "Human Connection gGmbH",
"license": "MIT",

View File

@ -35,7 +35,7 @@ class Store {
const session = driver.session()
const readTxResultPromise = session.readTransaction(async txc => {
const result = await txc.run(
'MATCH (migration:Migration) RETURN migration {.*} ORDER BY migration.migratedAt DESC',
'MATCH (migration:Migration) RETURN migration {.*} ORDER BY migration.timestamp DESC',
)
return result.records.map(r => r.get('migration'))
})
@ -65,14 +65,16 @@ class Store {
const writeTxResultPromise = session.writeTransaction(txc => {
return Promise.all(
migrations.map(async migration => {
const { title, description } = migration
const properties = { title, description }
const { title, description, timestamp } = migration
const properties = { title, description, timestamp }
const migrationResult = await txc.run(
`
MERGE (migration:Migration { title: $properties.title })
ON CREATE SET migration += $properties,
ON MATCH SET
migration += $properties
ON CREATE SET
migration += $properties,
migration.migratedAt = toString(datetime())
RETURN migration
`,
{ properties },
)

View File

@ -33,7 +33,7 @@ export function up(next) {
`
MATCH(location:Location {id: $locationId}), (location2:Location {id: $locationId})
WHERE location.id = location2.id AND id(location) < id(location2)
CALL apoc.refactor.mergeNodes([location, location2], { properties: 'combine' }) YIELD node as updatedLocation
CALL apoc.refactor.mergeNodes([location, location2], { properties: 'combine', mergeRels: true }) YIELD node as updatedLocation
RETURN location {.*},updatedLocation {.*}
`,
{ locationId },