mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
* eslint import * eslint comments * eslint security * eslint import - rules * eslint n * eslint promise * eslint no-catch-all * eslint jest * missing ignore * disable import/unambiguous as conflicting
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { getDriver } from '../neo4j'
|
|
|
|
export const description = 'Add to all existing posts the Article label'
|
|
|
|
export async function up(next) {
|
|
const driver = getDriver()
|
|
const session = driver.session()
|
|
const transaction = session.beginTransaction()
|
|
|
|
try {
|
|
await transaction.run(`
|
|
MATCH (post:Post)
|
|
SET post:Article
|
|
RETURN post
|
|
`)
|
|
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 {
|
|
await transaction.run(`
|
|
MATCH (post:Post)
|
|
REMOVE post:Article
|
|
RETURN post
|
|
`)
|
|
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()
|
|
}
|
|
}
|