mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Migrate renamed group properties 'description' to 'groupDescription', 'descriptionExcerpt' to 'groupDescriptionExcerpt'
This commit is contained in:
parent
3ba4467fe4
commit
0147d2f364
@ -0,0 +1,60 @@
|
||||
import { getDriver } from '../neo4j'
|
||||
|
||||
export const description = `
|
||||
We change the full-text index on node label 'Group' from property 'description' to 'groupDescription'.
|
||||
This belongs to next migration '20221109201106-change_group_properties_from_description_to_groupDescription'.
|
||||
`
|
||||
|
||||
export async function up(next) {
|
||||
const driver = getDriver()
|
||||
const session = driver.session()
|
||||
const transaction = session.beginTransaction()
|
||||
|
||||
try {
|
||||
// Implement your migration here.
|
||||
await transaction.run(`
|
||||
CALL db.index.fulltext.drop('group_fulltext_search')
|
||||
`)
|
||||
await transaction.run(`
|
||||
CALL db.index.fulltext.createNodeIndex("group_fulltext_search",["Group"],["name", "slug", "about", "groupDescription"])
|
||||
`)
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
|
||||
export async function down(next) {
|
||||
const driver = getDriver()
|
||||
const session = driver.session()
|
||||
const transaction = session.beginTransaction()
|
||||
|
||||
try {
|
||||
// Implement your migration here.
|
||||
await transaction.run(`
|
||||
CALL db.index.fulltext.drop('group_fulltext_search')
|
||||
`)
|
||||
await transaction.run(`
|
||||
CALL db.index.fulltext.createNodeIndex("group_fulltext_search",["Group"],["name", "slug", "about", "description"])
|
||||
`)
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
import { getDriver } from '../neo4j'
|
||||
|
||||
export const description = `
|
||||
We change on node label 'Group':
|
||||
– properties name 'description' to 'groupDescription'
|
||||
– properties name 'descriptionExcerpt' to 'groupDescriptionExcerpt'
|
||||
This belongs to further migration '20221109171154-change_group_fulltext_index_for_property_description_to_groupDescription'.
|
||||
`
|
||||
|
||||
export async function up(next) {
|
||||
const driver = getDriver()
|
||||
const session = driver.session()
|
||||
const transaction = session.beginTransaction()
|
||||
|
||||
try {
|
||||
// Implement your migration here.
|
||||
await transaction.run(`
|
||||
MATCH (group:Group)
|
||||
SET group.groupDescription = group.description
|
||||
REMOVE group.description
|
||||
SET group.groupDescriptionExcerpt = group.descriptionExcerpt
|
||||
REMOVE group.descriptionExcerpt
|
||||
`)
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
|
||||
export async function down(next) {
|
||||
const driver = getDriver()
|
||||
const session = driver.session()
|
||||
const transaction = session.beginTransaction()
|
||||
|
||||
try {
|
||||
// Implement your migration here.
|
||||
await transaction.run(`
|
||||
MATCH (group:Group)
|
||||
SET group.description = group.groupDescription
|
||||
REMOVE group.groupDescription
|
||||
SET group.descriptionExcerpt = group.groupDescriptionExcerpt
|
||||
REMOVE group.groupDescriptionExcerpt
|
||||
`)
|
||||
await transaction.commit()
|
||||
next()
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
await transaction.rollback()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('rolled back')
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
@ -103,17 +103,17 @@ $ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backen
|
||||
```bash
|
||||
# in browser command line or cypher shell
|
||||
|
||||
# show all indexes and contraints
|
||||
# show all indexes and constraints
|
||||
$ :schema
|
||||
|
||||
# show all indexes
|
||||
$ CALL db.indexes();
|
||||
|
||||
# show all contraints
|
||||
# show all constraints
|
||||
$ CALL db.constraints();
|
||||
```
|
||||
|
||||
***Cypher commands to create and drop indexes and contraints***
|
||||
***Cypher commands to create and drop indexes and constraints***
|
||||
|
||||
```bash
|
||||
# in browser command line or cypher shell
|
||||
@ -122,9 +122,17 @@ $ CALL db.constraints();
|
||||
$ 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("tag_fulltext_search",["Tag"],["id"]);
|
||||
$ CALL db.index.fulltext.createNodeIndex("group_fulltext_search",["Group"],["name", "slug", "about", "description"])
|
||||
|
||||
# drop an index
|
||||
$ DROP CONSTRAINT ON ( image:Image ) ASSERT image.url IS UNIQUE
|
||||
$ CALL db.index.fulltext.drop('post_fulltext_search')
|
||||
$ CALL db.index.fulltext.drop('group_fulltext_search')
|
||||
|
||||
# create constraint
|
||||
$ CREATE CONSTRAINT ON ( group:Group ) ASSERT group.id IS UNIQUE
|
||||
|
||||
# drop a constraint
|
||||
$ DROP CONSTRAINT ON ( group:Group ) ASSERT group.id IS UNIQUE
|
||||
|
||||
# drop all indexes and contraints
|
||||
$ CALL apoc.schema.assert({},{},true) YIELD label, key RETURN * ;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user