mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
* clean migrate scripts - refactor migrate:init - separate admin seed - separate categories seed - rework backend README regarding the database - remove `db:clean` command as its a duplicate of `db:reset` - remove `__migrate` helper alias * renamed clean.ts to reset.ts * set indices & constrains in init function * fix comment * disable migrations touching indices * remove obsolete comment * always run init on kubernetes * reset db with or without migrations * lint fixes * Refine 'README.md' * Refine more 'README.md' * fix lint --------- Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
37 lines
1003 B
TypeScript
37 lines
1003 B
TypeScript
import { categories } from '@constants/categories'
|
|
|
|
import { getDriver } from './neo4j'
|
|
|
|
const createCategories = async () => {
|
|
const driver = getDriver()
|
|
const session = driver.session()
|
|
const createCategoriesTxResultPromise = session.writeTransaction(async (txc) => {
|
|
categories.forEach(({ icon, name }, index) => {
|
|
const id = `cat${index + 1}`
|
|
txc.run(
|
|
`MERGE (c:Category {
|
|
icon: "${icon}",
|
|
slug: "${name}",
|
|
name: "${name}",
|
|
id: "${id}",
|
|
createdAt: toString(datetime())
|
|
})`,
|
|
)
|
|
})
|
|
})
|
|
try {
|
|
await createCategoriesTxResultPromise
|
|
console.log('Successfully created categories!') // eslint-disable-line no-console
|
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
} catch (error) {
|
|
console.log(`Error creating categories: ${error}`) // eslint-disable-line no-console
|
|
} finally {
|
|
session.close()
|
|
driver.close()
|
|
}
|
|
}
|
|
|
|
;(async function () {
|
|
await createCategories()
|
|
})()
|