@sphereon/ssi-sdk.data-store
Version:
96 lines • 5.65 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateStatusList1737110469000 = void 0;
class UpdateStatusList1737110469000 {
constructor() {
this.name = 'UpdateStatusList1737110469000';
}
up(queryRunner) {
return __awaiter(this, void 0, void 0, function* () {
// Create temporary table with new schema
yield queryRunner.query(`CREATE TABLE "temporary_StatusList" (
"id" varchar PRIMARY KEY NOT NULL,
"correlationId" varchar NOT NULL,
"length" integer NOT NULL,
"issuer" text NOT NULL,
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
"statusPurpose" varchar,
"statusListCredential" text,
"bitsPerStatus" integer,
"expiresAt" datetime,
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
)`);
// Copy data from old table to temporary table
yield queryRunner.query(`INSERT INTO "temporary_StatusList"(
"id", "correlationId", "length", "issuer", "type", "driverType",
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
"statusListCredential"
)
SELECT
"id", "correlationId", "length", "issuer", "type", "driverType",
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
"statusListCredential"
FROM "StatusList"`);
// Drop old table and rename temporary table
yield queryRunner.query(`DROP TABLE "StatusList"`);
yield queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
});
}
down(queryRunner) {
return __awaiter(this, void 0, void 0, function* () {
yield queryRunner.query(`
ALTER TABLE "StatusListEntry"
RENAME COLUMN "entryCorrelationId" TO "correlationId"
`);
yield queryRunner.query(`
ALTER TABLE "StatusListEntry"
DROP COLUMN "statusListCorrelationId"
`);
// Create temporary table with old schema
yield queryRunner.query(`CREATE TABLE "temporary_StatusList" (
"id" varchar PRIMARY KEY NOT NULL,
"correlationId" varchar NOT NULL,
"length" integer NOT NULL,
"issuer" text NOT NULL,
"type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
"statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
"statusListCredential" text,
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
)`);
// Copy data back, excluding new columns
yield queryRunner.query(`INSERT INTO "temporary_StatusList"(
"id", "correlationId", "length", "issuer", "type", "driverType",
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
"statusListCredential"
)
SELECT
"id", "correlationId", "length", "issuer",
CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
COALESCE("statusPurpose", 'revocation'), "statusListCredential"
FROM "StatusList"`);
// Drop new table and rename temporary table back
yield queryRunner.query(`DROP TABLE "StatusList"`);
yield queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
});
}
}
exports.UpdateStatusList1737110469000 = UpdateStatusList1737110469000;
//# sourceMappingURL=1737110469000-UpdateStatusList.js.map