src/database/migrations/1769000000000-RemovePreferredAuthServerFromIssuanceConfig.ts

Description

Remove legacy preferred authorization server selection from issuance_config.

Authorization server priority is now inferred from the order of authorizationServers[] in configuration.

Implements

MigrationInterface

Relationships

Used by

No results matching.

Depends on

  • MigrationInterface

Index

Properties
Methods
  • Public Async down
  • Public Async up

Properties

name
Type : string
Default value : "RemovePreferredAuthServerFromIssuanceConfig1769000000000"

Methods

Public Async down
down(queryRunner: QueryRunner)
Parameters :
Name Type Optional
queryRunner QueryRunner No
Returns : Promise<void>
Public Async up
up(queryRunner: QueryRunner)
Parameters :
Name Type Optional
queryRunner QueryRunner No
Returns : Promise<void>
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";

/**
 * Remove legacy preferred authorization server selection from issuance_config.
 *
 * Authorization server priority is now inferred from the order of
 * authorizationServers[] in configuration.
 */
export class RemovePreferredAuthServerFromIssuanceConfig1769000000000
    implements MigrationInterface
{
    name = "RemovePreferredAuthServerFromIssuanceConfig1769000000000";

    public async up(queryRunner: QueryRunner): Promise<void> {
        const issuanceConfigTable =
            await queryRunner.getTable("issuance_config");

        if (!issuanceConfigTable) {
            console.log(
                "[Migration] issuance_config table not found - skipping (schema may not exist yet).",
            );
            return;
        }

        const hasPreferredAuthServer = issuanceConfigTable.columns.some(
            (col) => col.name === "preferredAuthServer",
        );
        if (hasPreferredAuthServer) {
            await queryRunner.dropColumn(
                "issuance_config",
                "preferredAuthServer",
            );
            console.log(
                "[Migration] Dropped preferredAuthServer from issuance_config.",
            );
        }
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        const issuanceConfigTable =
            await queryRunner.getTable("issuance_config");

        if (!issuanceConfigTable) {
            console.log(
                "[Migration] issuance_config table not found - skipping (schema may not exist yet).",
            );
            return;
        }

        const hasPreferredAuthServer = issuanceConfigTable.columns.some(
            (col) => col.name === "preferredAuthServer",
        );
        if (!hasPreferredAuthServer) {
            await queryRunner.addColumn(
                "issuance_config",
                new TableColumn({
                    name: "preferredAuthServer",
                    type: "varchar",
                    isNullable: true,
                }),
            );
            console.log(
                "[Migration] Re-added preferredAuthServer to issuance_config.",
            );
        }
    }
}

results matching ""

    No results matching ""