throw error added to template

This commit is contained in:
Moriz Wahl 2020-02-18 14:16:46 +01:00
parent 31cec2cf0c
commit 5b41561cc4
2 changed files with 10 additions and 4 deletions

View File

@ -18,6 +18,7 @@ export async function up(next) {
await transaction.rollback()
// eslint-disable-next-line no-console
console.log('rolled back')
throw new Error(error)
} finally {
session.close()
}

View File

@ -1,7 +1,12 @@
import { getDriver } from '../../db/neo4j'
export const description =
'This migration swaps the value stored in Location.lat with the value of Location.lng.'
export const description = `
This migration swaps the value stored in Location.lat with the value
of Location.lng. This is necessary as the values of lat and lng were
stored incorrectly. For example Hamburg, Germany, was stored with the
values lat=10.0 and lng=53.55, which is close to the horn of Africa,
but it is lat=53.55 and lng=10.0
`
const swap = async function(next) {
const driver = getDriver()
@ -11,8 +16,8 @@ const swap = async function(next) {
// Implement your migration here.
await transaction.run(`
MATCH (l:Location) WHERE NOT(l.lat IS NULL)
WITH l.lng AS longitude, l.lat AS latitude, l AS Location
SET Location.lat = longitude, Location.lng = latitude
WITH l.lng AS longitude, l.lat AS latitude, l AS location
SET location.lat = longitude, location.lng = latitude
`)
await transaction.commit()
next()