fix: harden world travel migration

This commit is contained in:
Bastian Wagner
2026-08-18 19:03:21 +02:00
parent 492765d8ca
commit 21f701e904
5 changed files with 131 additions and 27 deletions

View File

@@ -2,9 +2,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
export class CreateVisibleVerticalSlice1787072400000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"');
await queryRunner.query(`CREATE TABLE "location_definitions" (
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
"key" character varying(100) NOT NULL,
"name" character varying(150) NOT NULL,
"description" text NOT NULL,
@@ -23,7 +22,7 @@ export class CreateVisibleVerticalSlice1787072400000 implements MigrationInterfa
'CREATE UNIQUE INDEX "IDX_location_definitions_key" ON "location_definitions" ("key")',
);
await queryRunner.query(`CREATE TABLE "characters" (
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
"name" character varying(150) NOT NULL,
"level" integer NOT NULL,
"experience" integer NOT NULL,
@@ -40,7 +39,7 @@ export class CreateVisibleVerticalSlice1787072400000 implements MigrationInterfa
'CREATE INDEX "IDX_characters_current_location" ON "characters" ("current_location_id")',
);
await queryRunner.query(`CREATE TABLE "location_connections" (
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
"from_location_id" uuid NOT NULL,
"to_location_id" uuid NOT NULL,
"travel_duration_seconds" integer NOT NULL,
@@ -62,7 +61,7 @@ export class CreateVisibleVerticalSlice1787072400000 implements MigrationInterfa
"CREATE TYPE \"travel_status_enum\" AS ENUM ('TRAVELLING', 'COMPLETED')",
);
await queryRunner.query(`CREATE TABLE "travels" (
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
"character_id" uuid NOT NULL,
"origin_location_id" uuid NOT NULL,
"target_location_id" uuid NOT NULL,