diff --git a/backend/src/data-source.ts b/backend/src/data-source.ts index 0d300af..560cc82 100644 --- a/backend/src/data-source.ts +++ b/backend/src/data-source.ts @@ -36,6 +36,7 @@ import { FixCategoriesSectionTypeExpressionIndex1779700000000 } from './migratio import { AddStepNameToEtlRun1779710000000 } from './migrations/1779710000000-AddStepNameToEtlRun'; import { AddUniqueUuidToStationItem1780010901444 } from './migrations/1780010901444-AddUniqueUuidToStationItem'; import { MakeItemFksDeferrable1780020000000 } from './migrations/1780020000000-MakeItemFksDeferrable'; +import { MigrateTablePksToUuidV71780030000000 } from './migrations/1780030000000-MigrateTablePksToUuidV7'; export const AppDataSource = new DataSource({ type: 'postgres', @@ -81,6 +82,7 @@ export const AppDataSource = new DataSource({ AddStepNameToEtlRun1779710000000, AddUniqueUuidToStationItem1780010901444, MakeItemFksDeferrable1780020000000, + MigrateTablePksToUuidV71780030000000, ], synchronize: false, extra: { parseInt8: true }, diff --git a/backend/src/migrations/1780030000000-MigrateTablePksToUuidV7.ts b/backend/src/migrations/1780030000000-MigrateTablePksToUuidV7.ts new file mode 100644 index 0000000..5114ba3 --- /dev/null +++ b/backend/src/migrations/1780030000000-MigrateTablePksToUuidV7.ts @@ -0,0 +1,287 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class MigrateTablePksToUuidV71780030000000 + implements MigrationInterface +{ + name = 'MigrateTablePksToUuidV71780030000000'; + + public async up(queryRunner: QueryRunner): Promise { + // ------------------------------------------------------------------------- + // station_* tables — pure SQL tables, no TypeORM entity management + // Order: leaf tables first, then tables with FKs pointing at them + // ------------------------------------------------------------------------- + + // Drop FK constraints on station_terminal before altering referenced tables + await queryRunner.query(` + ALTER TABLE station_terminal + DROP CONSTRAINT IF EXISTS station_terminal_star_system_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_planet_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_orbit_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_moon_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_space_station_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_outpost_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_poi_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_city_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_faction_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_company_id_fkey + `); + + // Drop FK on station_terminal_distance before altering station_terminal + await queryRunner.query(` + ALTER TABLE station_terminal_distance + DROP CONSTRAINT IF EXISTS station_terminal_distance_terminal_origin_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_distance_terminal_destination_id_fkey + `); + + const stationTables = [ + 'station_faction', + 'station_jurisdiction', + 'station_company', + 'station_star_system', + 'station_orbit', + 'station_orbit_distance', + 'station_planet', + 'station_moon', + 'station_city', + 'station_space_station', + 'station_outpost', + 'station_poi', + 'station_terminal', + 'station_terminal_distance', + ]; + + for (const table of stationTables) { + await queryRunner.query(` + ALTER TABLE "${table}" + ALTER COLUMN id DROP DEFAULT, + ALTER COLUMN id TYPE UUID USING gen_random_uuid(), + ALTER COLUMN id SET DEFAULT gen_random_uuid() + `); + } + + // Convert station_terminal FK columns from BIGINT to UUID + const terminalFkCols = [ + 'star_system_id', + 'planet_id', + 'orbit_id', + 'moon_id', + 'space_station_id', + 'outpost_id', + 'poi_id', + 'city_id', + 'faction_id', + 'company_id', + ]; + for (const col of terminalFkCols) { + await queryRunner.query(` + ALTER TABLE station_terminal + ALTER COLUMN ${col} TYPE UUID USING NULL::UUID + `); + } + + // Convert station_terminal_distance FK columns + await queryRunner.query(` + ALTER TABLE station_terminal_distance + ALTER COLUMN terminal_origin_id TYPE UUID USING NULL::UUID, + ALTER COLUMN terminal_destination_id TYPE UUID USING NULL::UUID + `); + + // Restore FKs on station_terminal + await queryRunner.query(` + ALTER TABLE station_terminal + ADD CONSTRAINT station_terminal_star_system_id_fkey + FOREIGN KEY (star_system_id) REFERENCES station_star_system(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_planet_id_fkey + FOREIGN KEY (planet_id) REFERENCES station_planet(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_orbit_id_fkey + FOREIGN KEY (orbit_id) REFERENCES station_orbit(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_moon_id_fkey + FOREIGN KEY (moon_id) REFERENCES station_moon(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_space_station_id_fkey + FOREIGN KEY (space_station_id) REFERENCES station_space_station(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_outpost_id_fkey + FOREIGN KEY (outpost_id) REFERENCES station_outpost(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_poi_id_fkey + FOREIGN KEY (poi_id) REFERENCES station_poi(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_city_id_fkey + FOREIGN KEY (city_id) REFERENCES station_city(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_faction_id_fkey + FOREIGN KEY (faction_id) REFERENCES station_faction(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_company_id_fkey + FOREIGN KEY (company_id) REFERENCES station_company(id) ON DELETE SET NULL + `); + + // Restore FKs on station_terminal_distance + await queryRunner.query(` + ALTER TABLE station_terminal_distance + ADD CONSTRAINT station_terminal_distance_terminal_origin_id_fkey + FOREIGN KEY (terminal_origin_id) REFERENCES station_terminal(id) ON DELETE CASCADE, + ADD CONSTRAINT station_terminal_distance_terminal_destination_id_fkey + FOREIGN KEY (terminal_destination_id) REFERENCES station_terminal(id) ON DELETE CASCADE + `); + + // ------------------------------------------------------------------------- + // uex_* tables — TypeORM-managed entities + // These tables have no cross-table FKs on the id column (relations join on + // uex_id, not id), so they can be altered independently. + // ------------------------------------------------------------------------- + + const uexTables = [ + 'uex_star_system', + 'uex_planet', + 'uex_moon', + 'uex_city', + 'uex_space_station', + 'uex_outpost', + 'uex_poi', + 'uex_company', + 'uex_category', + 'uex_commodity', + 'uex_item', + ]; + + for (const table of uexTables) { + await queryRunner.query(` + ALTER TABLE "${table}" + ALTER COLUMN id DROP DEFAULT, + ALTER COLUMN id TYPE UUID USING gen_random_uuid(), + ALTER COLUMN id SET DEFAULT gen_random_uuid() + `); + } + } + + public async down(queryRunner: QueryRunner): Promise { + // Drop restored FKs + await queryRunner.query(` + ALTER TABLE station_terminal + DROP CONSTRAINT IF EXISTS station_terminal_star_system_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_planet_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_orbit_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_moon_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_space_station_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_outpost_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_poi_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_city_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_faction_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_company_id_fkey + `); + + await queryRunner.query(` + ALTER TABLE station_terminal_distance + DROP CONSTRAINT IF EXISTS station_terminal_distance_terminal_origin_id_fkey, + DROP CONSTRAINT IF EXISTS station_terminal_distance_terminal_destination_id_fkey + `); + + // Revert station_terminal FK columns to BIGINT + const terminalFkCols = [ + 'star_system_id', + 'planet_id', + 'orbit_id', + 'moon_id', + 'space_station_id', + 'outpost_id', + 'poi_id', + 'city_id', + 'faction_id', + 'company_id', + ]; + for (const col of terminalFkCols) { + await queryRunner.query(` + ALTER TABLE station_terminal + ALTER COLUMN ${col} TYPE BIGINT USING NULL::BIGINT + `); + } + + await queryRunner.query(` + ALTER TABLE station_terminal_distance + ALTER COLUMN terminal_origin_id TYPE BIGINT USING NULL::BIGINT, + ALTER COLUMN terminal_destination_id TYPE BIGINT USING NULL::BIGINT + `); + + // Revert station_* PKs to BIGSERIAL + const stationTables = [ + 'station_terminal_distance', + 'station_terminal', + 'station_poi', + 'station_outpost', + 'station_space_station', + 'station_city', + 'station_moon', + 'station_planet', + 'station_orbit_distance', + 'station_orbit', + 'station_star_system', + 'station_company', + 'station_jurisdiction', + 'station_faction', + ]; + + for (const table of stationTables) { + await queryRunner.query(` + CREATE SEQUENCE IF NOT EXISTS "${table}_id_seq"; + ALTER TABLE "${table}" + ALTER COLUMN id DROP DEFAULT, + ALTER COLUMN id TYPE BIGINT USING NULL::BIGINT, + ALTER COLUMN id SET DEFAULT nextval('"${table}_id_seq"') + `); + } + + // Revert uex_* PKs + const uexTables = [ + 'uex_item', + 'uex_commodity', + 'uex_category', + 'uex_company', + 'uex_poi', + 'uex_outpost', + 'uex_space_station', + 'uex_city', + 'uex_moon', + 'uex_planet', + 'uex_star_system', + ]; + + for (const table of uexTables) { + await queryRunner.query(` + CREATE SEQUENCE IF NOT EXISTS "${table}_id_seq"; + ALTER TABLE "${table}" + ALTER COLUMN id DROP DEFAULT, + ALTER COLUMN id TYPE BIGINT USING NULL::BIGINT, + ALTER COLUMN id SET DEFAULT nextval('"${table}_id_seq"') + `); + } + + // Restore FKs on station_terminal + await queryRunner.query(` + ALTER TABLE station_terminal + ADD CONSTRAINT station_terminal_star_system_id_fkey + FOREIGN KEY (star_system_id) REFERENCES station_star_system(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_planet_id_fkey + FOREIGN KEY (planet_id) REFERENCES station_planet(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_orbit_id_fkey + FOREIGN KEY (orbit_id) REFERENCES station_orbit(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_moon_id_fkey + FOREIGN KEY (moon_id) REFERENCES station_moon(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_space_station_id_fkey + FOREIGN KEY (space_station_id) REFERENCES station_space_station(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_outpost_id_fkey + FOREIGN KEY (outpost_id) REFERENCES station_outpost(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_poi_id_fkey + FOREIGN KEY (poi_id) REFERENCES station_poi(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_city_id_fkey + FOREIGN KEY (city_id) REFERENCES station_city(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_faction_id_fkey + FOREIGN KEY (faction_id) REFERENCES station_faction(id) ON DELETE SET NULL, + ADD CONSTRAINT station_terminal_company_id_fkey + FOREIGN KEY (company_id) REFERENCES station_company(id) ON DELETE SET NULL + `); + + await queryRunner.query(` + ALTER TABLE station_terminal_distance + ADD CONSTRAINT station_terminal_distance_terminal_origin_id_fkey + FOREIGN KEY (terminal_origin_id) REFERENCES station_terminal(id) ON DELETE CASCADE, + ADD CONSTRAINT station_terminal_distance_terminal_destination_id_fkey + FOREIGN KEY (terminal_destination_id) REFERENCES station_terminal(id) ON DELETE CASCADE + `); + } +} diff --git a/backend/src/modules/org-inventory/org-inventory.service.spec.ts b/backend/src/modules/org-inventory/org-inventory.service.spec.ts index 1945eca..12f86a4 100644 --- a/backend/src/modules/org-inventory/org-inventory.service.spec.ts +++ b/backend/src/modules/org-inventory/org-inventory.service.spec.ts @@ -28,7 +28,11 @@ describe('OrgInventoryService', () => { const mockOrg: Organization = { id: 1, name: 'Test Org' } as Organization; const mockGame: Game = { id: 1, name: 'Star Citizen' } as Game; - const mockItem: UexItem = { id: 1, uexId: 100, name: 'Test Item' } as UexItem; + const mockItem: UexItem = { + id: 'uuid-test-1', + uexId: 100, + name: 'Test Item', + } as UexItem; const mockUser: User = { id: 1, username: 'testuser' } as User; const mockOrgInventoryItem: OrgInventoryItem = { diff --git a/backend/src/modules/uex/entities/uex-category.entity.spec.ts b/backend/src/modules/uex/entities/uex-category.entity.spec.ts index 64c7134..973dde9 100644 --- a/backend/src/modules/uex/entities/uex-category.entity.spec.ts +++ b/backend/src/modules/uex/entities/uex-category.entity.spec.ts @@ -3,7 +3,7 @@ import { UexCategory } from './uex-category.entity'; describe('UexCategory Entity', () => { it('should create a UexCategory instance', () => { const category = new UexCategory(); - category.id = 1; + category.id = 'uuid-test-1'; category.uexId = 100; category.name = 'Test Category'; category.type = 'item'; @@ -13,7 +13,7 @@ describe('UexCategory Entity', () => { category.deleted = false; expect(category).toBeDefined(); - expect(category.id).toBe(1); + expect(category.id).toBe('uuid-test-1'); expect(category.uexId).toBe(100); expect(category.name).toBe('Test Category'); expect(category.type).toBe('item'); diff --git a/backend/src/modules/uex/entities/uex-category.entity.ts b/backend/src/modules/uex/entities/uex-category.entity.ts index c4a3e7a..5b6837c 100644 --- a/backend/src/modules/uex/entities/uex-category.entity.ts +++ b/backend/src/modules/uex/entities/uex-category.entity.ts @@ -10,8 +10,8 @@ import { BaseUexEntity } from './base-uex.entity'; where: 'deleted = FALSE', }) export class UexCategory extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ length: 50, nullable: true }) type?: string; diff --git a/backend/src/modules/uex/entities/uex-city.entity.ts b/backend/src/modules/uex/entities/uex-city.entity.ts index 3b090c3..78ac888 100644 --- a/backend/src/modules/uex/entities/uex-city.entity.ts +++ b/backend/src/modules/uex/entities/uex-city.entity.ts @@ -21,8 +21,8 @@ import { UexMoon } from './uex-moon.entity'; `(planet_id IS NOT NULL AND moon_id IS NULL) OR (planet_id IS NULL AND moon_id IS NOT NULL)`, ) export class UexCity extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'planet_id', type: 'integer', nullable: true }) planetId?: number; diff --git a/backend/src/modules/uex/entities/uex-commodity.entity.ts b/backend/src/modules/uex/entities/uex-commodity.entity.ts index 9627bc8..b6ab843 100644 --- a/backend/src/modules/uex/entities/uex-commodity.entity.ts +++ b/backend/src/modules/uex/entities/uex-commodity.entity.ts @@ -27,8 +27,8 @@ import { UexCategory } from './uex-category.entity'; }) @Index('idx_uex_commodities_name', ['name'], { where: 'deleted = FALSE' }) export class UexCommodity extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'id_category', type: 'integer', nullable: true }) idCategory?: number; diff --git a/backend/src/modules/uex/entities/uex-company.entity.spec.ts b/backend/src/modules/uex/entities/uex-company.entity.spec.ts index e02a996..e01dcae 100644 --- a/backend/src/modules/uex/entities/uex-company.entity.spec.ts +++ b/backend/src/modules/uex/entities/uex-company.entity.spec.ts @@ -3,7 +3,7 @@ import { UexCompany } from './uex-company.entity'; describe('UexCompany Entity', () => { it('should create a UexCompany instance', () => { const company = new UexCompany(); - company.id = 1; + company.id = 'uuid-test-1'; company.uexId = 200; company.name = 'Anvil Aerospace'; company.code = 'ANVL'; @@ -11,7 +11,7 @@ describe('UexCompany Entity', () => { company.deleted = false; expect(company).toBeDefined(); - expect(company.id).toBe(1); + expect(company.id).toBe('uuid-test-1'); expect(company.uexId).toBe(200); expect(company.name).toBe('Anvil Aerospace'); expect(company.code).toBe('ANVL'); diff --git a/backend/src/modules/uex/entities/uex-company.entity.ts b/backend/src/modules/uex/entities/uex-company.entity.ts index 86291aa..985d7f9 100644 --- a/backend/src/modules/uex/entities/uex-company.entity.ts +++ b/backend/src/modules/uex/entities/uex-company.entity.ts @@ -8,8 +8,8 @@ import { BaseUexEntity } from './base-uex.entity'; where: 'deleted = FALSE', }) export class UexCompany extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ length: 255 }) name!: string; diff --git a/backend/src/modules/uex/entities/uex-item.entity.spec.ts b/backend/src/modules/uex/entities/uex-item.entity.spec.ts index 14149d8..de71c04 100644 --- a/backend/src/modules/uex/entities/uex-item.entity.spec.ts +++ b/backend/src/modules/uex/entities/uex-item.entity.spec.ts @@ -5,7 +5,7 @@ import { UexCompany } from './uex-company.entity'; describe('UexItem Entity', () => { it('should create a UexItem instance', () => { const item = new UexItem(); - item.id = 1; + item.id = 'uuid-test-1'; item.uexId = 300; item.name = 'F7C Hornet'; item.starCitizenUuid = 'uuid-12345'; @@ -22,7 +22,7 @@ describe('UexItem Entity', () => { item.deleted = false; expect(item).toBeDefined(); - expect(item.id).toBe(1); + expect(item.id).toBe('uuid-test-1'); expect(item.uexId).toBe(300); expect(item.name).toBe('F7C Hornet'); expect(item.starCitizenUuid).toBe('uuid-12345'); diff --git a/backend/src/modules/uex/entities/uex-item.entity.ts b/backend/src/modules/uex/entities/uex-item.entity.ts index 9e99e7c..d36b9d0 100644 --- a/backend/src/modules/uex/entities/uex-item.entity.ts +++ b/backend/src/modules/uex/entities/uex-item.entity.ts @@ -25,8 +25,8 @@ import { UexCompany } from './uex-company.entity'; where: 'deleted = FALSE AND is_commodity = TRUE', }) export class UexItem extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'star_citizen_uuid', length: 255, nullable: true }) starCitizenUuid?: string; diff --git a/backend/src/modules/uex/entities/uex-moon.entity.ts b/backend/src/modules/uex/entities/uex-moon.entity.ts index df9e6ae..a4225a4 100644 --- a/backend/src/modules/uex/entities/uex-moon.entity.ts +++ b/backend/src/modules/uex/entities/uex-moon.entity.ts @@ -15,8 +15,8 @@ import { UexPlanet } from './uex-planet.entity'; }) @Index('idx_uex_moons_planet', ['planetId'], { where: 'deleted = FALSE' }) export class UexMoon extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'planet_id', type: 'integer' }) planetId!: number; diff --git a/backend/src/modules/uex/entities/uex-outpost.entity.ts b/backend/src/modules/uex/entities/uex-outpost.entity.ts index 74326d7..3aab4f2 100644 --- a/backend/src/modules/uex/entities/uex-outpost.entity.ts +++ b/backend/src/modules/uex/entities/uex-outpost.entity.ts @@ -17,8 +17,8 @@ import { UexMoon } from './uex-moon.entity'; @Index('idx_uex_outposts_planet', ['planetId'], { where: 'deleted = FALSE' }) @Index('idx_uex_outposts_moon', ['moonId'], { where: 'deleted = FALSE' }) export class UexOutpost extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'planet_id', type: 'integer', nullable: true }) planetId?: number; diff --git a/backend/src/modules/uex/entities/uex-planet.entity.spec.ts b/backend/src/modules/uex/entities/uex-planet.entity.spec.ts index 4c648c8..625e627 100644 --- a/backend/src/modules/uex/entities/uex-planet.entity.spec.ts +++ b/backend/src/modules/uex/entities/uex-planet.entity.spec.ts @@ -4,7 +4,7 @@ import { UexStarSystem } from './uex-star-system.entity'; describe('UexPlanet Entity', () => { it('should create a UexPlanet instance', () => { const planet = new UexPlanet(); - planet.id = 1; + planet.id = 'uuid-test-1'; planet.uexId = 10; planet.starSystemId = 1; planet.name = 'Hurston'; @@ -15,7 +15,7 @@ describe('UexPlanet Entity', () => { planet.deleted = false; expect(planet).toBeDefined(); - expect(planet.id).toBe(1); + expect(planet.id).toBe('uuid-test-1'); expect(planet.uexId).toBe(10); expect(planet.starSystemId).toBe(1); expect(planet.name).toBe('Hurston'); diff --git a/backend/src/modules/uex/entities/uex-planet.entity.ts b/backend/src/modules/uex/entities/uex-planet.entity.ts index 9b46daf..e8e61a1 100644 --- a/backend/src/modules/uex/entities/uex-planet.entity.ts +++ b/backend/src/modules/uex/entities/uex-planet.entity.ts @@ -17,8 +17,8 @@ import { UexStarSystem } from './uex-star-system.entity'; where: 'deleted = FALSE', }) export class UexPlanet extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'star_system_id', type: 'integer' }) starSystemId!: number; diff --git a/backend/src/modules/uex/entities/uex-poi.entity.ts b/backend/src/modules/uex/entities/uex-poi.entity.ts index b4ed528..19403f2 100644 --- a/backend/src/modules/uex/entities/uex-poi.entity.ts +++ b/backend/src/modules/uex/entities/uex-poi.entity.ts @@ -18,8 +18,8 @@ import { UexMoon } from './uex-moon.entity'; @Index('idx_uex_poi_system', ['starSystemId'], { where: 'deleted = FALSE' }) @Index('idx_uex_poi_type', ['type'], { where: 'deleted = FALSE' }) export class UexPoi extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'star_system_id', type: 'integer', nullable: true }) starSystemId?: number; diff --git a/backend/src/modules/uex/entities/uex-space-station.entity.ts b/backend/src/modules/uex/entities/uex-space-station.entity.ts index 54b6822..ddcfd72 100644 --- a/backend/src/modules/uex/entities/uex-space-station.entity.ts +++ b/backend/src/modules/uex/entities/uex-space-station.entity.ts @@ -19,8 +19,8 @@ import { UexMoon } from './uex-moon.entity'; where: 'deleted = FALSE', }) export class UexSpaceStation extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ name: 'star_system_id', type: 'integer', nullable: true }) starSystemId?: number; diff --git a/backend/src/modules/uex/entities/uex-star-system.entity.spec.ts b/backend/src/modules/uex/entities/uex-star-system.entity.spec.ts index a994400..8a37029 100644 --- a/backend/src/modules/uex/entities/uex-star-system.entity.spec.ts +++ b/backend/src/modules/uex/entities/uex-star-system.entity.spec.ts @@ -3,7 +3,7 @@ import { UexStarSystem } from './uex-star-system.entity'; describe('UexStarSystem Entity', () => { it('should create a UexStarSystem instance', () => { const starSystem = new UexStarSystem(); - starSystem.id = 1; + starSystem.id = 'uuid-test-1'; starSystem.uexId = 1; starSystem.name = 'Stanton'; starSystem.code = 'STAN'; @@ -12,7 +12,7 @@ describe('UexStarSystem Entity', () => { starSystem.deleted = false; expect(starSystem).toBeDefined(); - expect(starSystem.id).toBe(1); + expect(starSystem.id).toBe('uuid-test-1'); expect(starSystem.uexId).toBe(1); expect(starSystem.name).toBe('Stanton'); expect(starSystem.code).toBe('STAN'); diff --git a/backend/src/modules/uex/entities/uex-star-system.entity.ts b/backend/src/modules/uex/entities/uex-star-system.entity.ts index 8e1cb6a..788e631 100644 --- a/backend/src/modules/uex/entities/uex-star-system.entity.ts +++ b/backend/src/modules/uex/entities/uex-star-system.entity.ts @@ -7,8 +7,8 @@ import { BaseUexEntity } from './base-uex.entity'; }) @Index('idx_uex_star_systems_code', ['code'], { where: 'deleted = FALSE' }) export class UexStarSystem extends BaseUexEntity { - @PrimaryGeneratedColumn({ type: 'bigint' }) - id!: number; + @PrimaryGeneratedColumn('uuid') + id!: string; @Column({ length: 255 }) name!: string;