mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
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:
parent
28dae1f854
commit
e343701057
@ -120,7 +120,7 @@ you have to migrate your data e.g. because your data modeling has changed.
|
|||||||
{% tab title="Docker" %}
|
{% tab title="Docker" %}
|
||||||
Generate a data migration file:
|
Generate a data migration file:
|
||||||
```bash
|
```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/
|
# Edit the file in ./src/db/migrations/
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ $ docker-compose exec backend yarn run db:migrate up
|
|||||||
{% tab title="Without Docker" %}
|
{% tab title="Without Docker" %}
|
||||||
Generate a data migration file:
|
Generate a data migration file:
|
||||||
```bash
|
```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/
|
# Edit the file in ./src/db/migrations/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
"db:reset": "yarn run db:clean",
|
"db:reset": "yarn run db:clean",
|
||||||
"db:seed": "babel-node src/db/seed.js",
|
"db:seed": "babel-node src/db/seed.js",
|
||||||
"db:migrate": "yarn run __migrate --store ./src/db/migrate/store.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",
|
"author": "Human Connection gGmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class Store {
|
|||||||
const session = driver.session()
|
const session = driver.session()
|
||||||
const readTxResultPromise = session.readTransaction(async txc => {
|
const readTxResultPromise = session.readTransaction(async txc => {
|
||||||
const result = await txc.run(
|
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'))
|
return result.records.map(r => r.get('migration'))
|
||||||
})
|
})
|
||||||
@ -65,14 +65,16 @@ class Store {
|
|||||||
const writeTxResultPromise = session.writeTransaction(txc => {
|
const writeTxResultPromise = session.writeTransaction(txc => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
migrations.map(async migration => {
|
migrations.map(async migration => {
|
||||||
const { title, description } = migration
|
const { title, description, timestamp } = migration
|
||||||
const properties = { title, description }
|
const properties = { title, description, timestamp }
|
||||||
const migrationResult = await txc.run(
|
const migrationResult = await txc.run(
|
||||||
`
|
`
|
||||||
MERGE (migration:Migration { title: $properties.title })
|
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())
|
migration.migratedAt = toString(datetime())
|
||||||
RETURN migration
|
|
||||||
`,
|
`,
|
||||||
{ properties },
|
{ properties },
|
||||||
)
|
)
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export function up(next) {
|
|||||||
`
|
`
|
||||||
MATCH(location:Location {id: $locationId}), (location2:Location {id: $locationId})
|
MATCH(location:Location {id: $locationId}), (location2:Location {id: $locationId})
|
||||||
WHERE location.id = location2.id AND id(location) < id(location2)
|
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 {.*}
|
RETURN location {.*},updatedLocation {.*}
|
||||||
`,
|
`,
|
||||||
{ locationId },
|
{ locationId },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user