diff --git a/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js b/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js index f34240ce76..507c3a8e64 100644 --- a/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js +++ b/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js @@ -50,7 +50,7 @@ exports.up = async function up(knex) { // Step 1: Add column as nullable so the schema change itself needs no data. await knex.schema.alterTable('locations', table => { table - .text('location_entity_ref') + .string('location_entity_ref') .nullable() .comment( 'The entity ref of the corresponding Location kind entity, e.g. location:default/generated-', @@ -126,7 +126,7 @@ exports.up = async function up(knex) { // MySQL: MODIFY COLUMN rewrites the column definition. // SQLite: knex recreates the table to enforce the NOT NULL constraint. await knex.schema.alterTable('locations', table => { - table.text('location_entity_ref').notNullable().alter(); + table.string('location_entity_ref').notNullable().alter(); }); } }; diff --git a/plugins/catalog-backend/report.sql.md b/plugins/catalog-backend/report.sql.md index 56340ad620..62a384adc2 100644 --- a/plugins/catalog-backend/report.sql.md +++ b/plugins/catalog-backend/report.sql.md @@ -46,7 +46,7 @@ | Column | Type | Nullable | Max Length | Default | | --------------------- | ------------------- | -------- | ---------- | ------- | | `id` | `uuid` | false | - | - | -| `location_entity_ref` | `text` | false | - | - | +| `location_entity_ref` | `character varying` | false | 255 | - | | `target` | `text` | true | - | - | | `type` | `character varying` | false | 255 | - | diff --git a/plugins/catalog-backend/src/util/conversion.ts b/plugins/catalog-backend/src/util/conversion.ts index c499715db5..5f7371375e 100644 --- a/plugins/catalog-backend/src/util/conversion.ts +++ b/plugins/catalog-backend/src/util/conversion.ts @@ -38,10 +38,11 @@ export function locationSpecToMetadataName(location: LocationSpec) { * stored location row, e.g. `location:default/generated-`. */ export function computeLocationEntityRef(type: string, target: string): string { - return `location:default/${locationSpecToMetadataName({ - type, - target, - })}`.toLocaleLowerCase('en-US'); + return stringifyEntityRef({ + kind: 'Location', + namespace: 'default', + name: locationSpecToMetadataName({ type, target }), + }); } export function locationSpecToLocationEntity(opts: {