@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.46.40 → 0.34.1-feature.SSISDK.50.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1618 -1417
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -166
- package/dist/index.d.ts +160 -166
- package/dist/index.js +1574 -1373
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2 -2
- package/src/__tests__/contact.store.test.ts +1 -1
- package/src/__tests__/digitalCredential.entities.test.ts +2 -1
- package/src/__tests__/digitalCredential.store.test.ts +5 -5
- package/src/__tests__/pd-manager.entities.test.ts +15 -37
- package/src/__tests__/pd-manager.store.test.ts +133 -0
- package/src/digitalCredential/DigitalCredentialStore.ts +9 -9
- package/src/entities/contact/IdentityEntity.ts +2 -1
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +2 -1
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +1 -1
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
- package/src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts +67 -0
- package/src/migrations/generic/index.ts +13 -5
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
- package/src/migrations/postgres/1756975509000-UpdatePresentationDefinitionItemNullable.ts +15 -0
- package/src/migrations/sqlite/1756975340000-UpdatePresentationDefinitionItemNullable.ts +77 -0
- package/src/presentationDefinition/PDStore.ts +6 -1
- package/src/types/contact/contact.ts +1 -1
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
- package/src/types/digitalCredential/enums.ts +1 -8
- package/src/types/digitalCredential/types.ts +2 -1
- package/src/types/presentationDefinition/presentationDefinition.ts +3 -3
- package/src/utils/presentationDefinition/MappingUtils.ts +32 -10
package/dist/index.js
CHANGED
|
@@ -8,55 +8,55 @@ import typeorm6 from "typeorm";
|
|
|
8
8
|
import typeorm5 from "typeorm";
|
|
9
9
|
|
|
10
10
|
// src/types/contact/contact.ts
|
|
11
|
-
var ConnectionType = /* @__PURE__ */
|
|
11
|
+
var ConnectionType = /* @__PURE__ */ function(ConnectionType2) {
|
|
12
12
|
ConnectionType2["OPENID_CONNECT"] = "OIDC";
|
|
13
13
|
ConnectionType2["SIOPv2"] = "SIOPv2";
|
|
14
14
|
ConnectionType2["SIOPv2_OpenID4VP"] = "SIOPv2+OpenID4VP";
|
|
15
15
|
return ConnectionType2;
|
|
16
|
-
}
|
|
17
|
-
var CorrelationIdentifierType = /* @__PURE__ */
|
|
16
|
+
}({});
|
|
17
|
+
var CorrelationIdentifierType = /* @__PURE__ */ function(CorrelationIdentifierType2) {
|
|
18
18
|
CorrelationIdentifierType2["DID"] = "did";
|
|
19
19
|
CorrelationIdentifierType2["URL"] = "url";
|
|
20
20
|
return CorrelationIdentifierType2;
|
|
21
|
-
}
|
|
22
|
-
var PartyTypeType = /* @__PURE__ */
|
|
21
|
+
}({});
|
|
22
|
+
var PartyTypeType = /* @__PURE__ */ function(PartyTypeType2) {
|
|
23
23
|
PartyTypeType2["NATURAL_PERSON"] = "naturalPerson";
|
|
24
24
|
PartyTypeType2["ORGANIZATION"] = "organization";
|
|
25
25
|
return PartyTypeType2;
|
|
26
|
-
}
|
|
27
|
-
var PartyOrigin = /* @__PURE__ */
|
|
26
|
+
}({});
|
|
27
|
+
var PartyOrigin = /* @__PURE__ */ function(PartyOrigin2) {
|
|
28
28
|
PartyOrigin2["INTERNAL"] = "INTERNAL";
|
|
29
29
|
PartyOrigin2["EXTERNAL"] = "EXTERNAL";
|
|
30
30
|
return PartyOrigin2;
|
|
31
|
-
}
|
|
32
|
-
var IdentityOrigin = /* @__PURE__ */
|
|
31
|
+
}({});
|
|
32
|
+
var IdentityOrigin = /* @__PURE__ */ function(IdentityOrigin2) {
|
|
33
33
|
IdentityOrigin2["INTERNAL"] = "INTERNAL";
|
|
34
34
|
IdentityOrigin2["EXTERNAL"] = "EXTERNAL";
|
|
35
35
|
return IdentityOrigin2;
|
|
36
|
-
}
|
|
36
|
+
}({});
|
|
37
37
|
|
|
38
38
|
// src/types/digitalCredential/enums.ts
|
|
39
|
-
var DocumentType = /* @__PURE__ */
|
|
39
|
+
var DocumentType = /* @__PURE__ */ function(DocumentType2) {
|
|
40
40
|
DocumentType2["VC"] = "VC";
|
|
41
41
|
DocumentType2["VP"] = "VP";
|
|
42
42
|
DocumentType2["P"] = "P";
|
|
43
43
|
DocumentType2["C"] = "C";
|
|
44
44
|
return DocumentType2;
|
|
45
|
-
}
|
|
46
|
-
var RegulationType = /* @__PURE__ */
|
|
45
|
+
}({});
|
|
46
|
+
var RegulationType = /* @__PURE__ */ function(RegulationType2) {
|
|
47
47
|
RegulationType2["PID"] = "PID";
|
|
48
48
|
RegulationType2["QEAA"] = "QEAA";
|
|
49
49
|
RegulationType2["EAA"] = "EAA";
|
|
50
50
|
RegulationType2["NON_REGULATED"] = "NON_REGULATED";
|
|
51
51
|
return RegulationType2;
|
|
52
|
-
}
|
|
53
|
-
var CredentialDocumentFormat = /* @__PURE__ */
|
|
52
|
+
}({});
|
|
53
|
+
var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat2) {
|
|
54
54
|
CredentialDocumentFormat2["JSON_LD"] = "JSON_LD";
|
|
55
55
|
CredentialDocumentFormat2["JWT"] = "JWT";
|
|
56
56
|
CredentialDocumentFormat2["SD_JWT"] = "SD_JWT";
|
|
57
57
|
CredentialDocumentFormat2["MSO_MDOC"] = "MSO_MDOC";
|
|
58
58
|
return CredentialDocumentFormat2;
|
|
59
|
-
}
|
|
59
|
+
}({});
|
|
60
60
|
(function(CredentialDocumentFormat2) {
|
|
61
61
|
function fromSpecValue(credentialFormat) {
|
|
62
62
|
const format = credentialFormat.toLowerCase();
|
|
@@ -77,7 +77,7 @@ var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentForma
|
|
|
77
77
|
function toSpecValue(documentFormat, documentType) {
|
|
78
78
|
switch (documentFormat) {
|
|
79
79
|
case "SD_JWT":
|
|
80
|
-
return "
|
|
80
|
+
return "dc+sd-jwt";
|
|
81
81
|
case "MSO_MDOC":
|
|
82
82
|
return "mso_mdoc";
|
|
83
83
|
case "JSON_LD":
|
|
@@ -89,26 +89,19 @@ var CredentialDocumentFormat = /* @__PURE__ */ (function(CredentialDocumentForma
|
|
|
89
89
|
__name(toSpecValue, "toSpecValue");
|
|
90
90
|
CredentialDocumentFormat2.toSpecValue = toSpecValue;
|
|
91
91
|
})(CredentialDocumentFormat || (CredentialDocumentFormat = {}));
|
|
92
|
-
var CredentialCorrelationType = /* @__PURE__ */
|
|
92
|
+
var CredentialCorrelationType = /* @__PURE__ */ function(CredentialCorrelationType2) {
|
|
93
93
|
CredentialCorrelationType2["DID"] = "DID";
|
|
94
94
|
CredentialCorrelationType2["X509_SAN"] = "X509_SAN";
|
|
95
95
|
CredentialCorrelationType2["KID"] = "KID";
|
|
96
96
|
CredentialCorrelationType2["URL"] = "URL";
|
|
97
97
|
return CredentialCorrelationType2;
|
|
98
|
-
}
|
|
99
|
-
var
|
|
100
|
-
CredentialRole2["ISSUER"] = "ISSUER";
|
|
101
|
-
CredentialRole2["VERIFIER"] = "VERIFIER";
|
|
102
|
-
CredentialRole2["HOLDER"] = "HOLDER";
|
|
103
|
-
CredentialRole2["FEDERATION_TRUST_ANCHOR"] = "FEDERATION_TRUST_ANCHOR";
|
|
104
|
-
return CredentialRole2;
|
|
105
|
-
})({});
|
|
106
|
-
var CredentialStateType = /* @__PURE__ */ (function(CredentialStateType2) {
|
|
98
|
+
}({});
|
|
99
|
+
var CredentialStateType = /* @__PURE__ */ function(CredentialStateType2) {
|
|
107
100
|
CredentialStateType2["REVOKED"] = "REVOKED";
|
|
108
101
|
CredentialStateType2["VERIFIED"] = "VERIFIED";
|
|
109
102
|
CredentialStateType2["EXPIRED"] = "EXPIRED";
|
|
110
103
|
return CredentialStateType2;
|
|
111
|
-
}
|
|
104
|
+
}({});
|
|
112
105
|
|
|
113
106
|
// src/entities/contact/IdentityEntity.ts
|
|
114
107
|
import { BaseEntity as BaseEntity8, CreateDateColumn as CreateDateColumn7, Entity as Entity10, PrimaryGeneratedColumn as PrimaryGeneratedColumn10, UpdateDateColumn as UpdateDateColumn7, OneToOne as OneToOne4, JoinColumn as JoinColumn5, ManyToOne as ManyToOne7, Column as Column9, OneToMany as OneToMany4, BeforeInsert as BeforeInsert10, BeforeUpdate as BeforeUpdate10 } from "typeorm";
|
|
@@ -3769,6 +3762,7 @@ AuditEventEntity = _ts_decorate32([
|
|
|
3769
3762
|
|
|
3770
3763
|
// src/entities/digitalCredential/DigitalCredentialEntity.ts
|
|
3771
3764
|
import { typeormDate, typeOrmDateTime as typeOrmDateTime16 } from "@sphereon/ssi-sdk.agent-config";
|
|
3765
|
+
import { CredentialRole } from "@sphereon/ssi-types";
|
|
3772
3766
|
import { BaseEntity as BaseEntity23, Column as Column30, CreateDateColumn as CreateDateColumn13, Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, UpdateDateColumn as UpdateDateColumn13 } from "typeorm";
|
|
3773
3767
|
function _ts_decorate33(decorators, target, key, desc) {
|
|
3774
3768
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -4126,7 +4120,7 @@ _ts_decorate34([
|
|
|
4126
4120
|
Column31({
|
|
4127
4121
|
name: "definition_payload",
|
|
4128
4122
|
type: "text",
|
|
4129
|
-
nullable:
|
|
4123
|
+
nullable: true,
|
|
4130
4124
|
unique: false
|
|
4131
4125
|
}),
|
|
4132
4126
|
IsNotEmpty12({
|
|
@@ -5346,6 +5340,7 @@ var AbstractDigitalCredentialStore = class {
|
|
|
5346
5340
|
};
|
|
5347
5341
|
|
|
5348
5342
|
// src/digitalCredential/DigitalCredentialStore.ts
|
|
5343
|
+
import { CredentialRole as CredentialRole2 } from "@sphereon/ssi-types";
|
|
5349
5344
|
import Debug2 from "debug";
|
|
5350
5345
|
|
|
5351
5346
|
// src/utils/SortingUtils.ts
|
|
@@ -5415,7 +5410,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
|
|
|
5415
5410
|
if (!args) {
|
|
5416
5411
|
return false;
|
|
5417
5412
|
}
|
|
5418
|
-
|
|
5413
|
+
const query = {};
|
|
5419
5414
|
if ("id" in args) {
|
|
5420
5415
|
query.id = args.id;
|
|
5421
5416
|
} else if ("hash" in args) {
|
|
@@ -5501,7 +5496,7 @@ var DigitalCredentialStore = class extends AbstractDigitalCredentialStore {
|
|
|
5501
5496
|
}, "updateCredentialState");
|
|
5502
5497
|
assertValidDigitalCredential(credentialEntity) {
|
|
5503
5498
|
const { kmsKeyRef, identifierMethod, credentialRole, isIssuerSigned } = credentialEntity;
|
|
5504
|
-
const isRoleInvalid = credentialRole ===
|
|
5499
|
+
const isRoleInvalid = credentialRole === CredentialRole2.ISSUER || credentialRole === CredentialRole2.HOLDER && !isIssuerSigned;
|
|
5505
5500
|
if (isRoleInvalid && (!kmsKeyRef || !identifierMethod)) {
|
|
5506
5501
|
const missingFields = [];
|
|
5507
5502
|
if (!kmsKeyRef) missingFields.push("kmsKeyRef");
|
|
@@ -6777,6 +6772,7 @@ import { In as In4 } from "typeorm";
|
|
|
6777
6772
|
import Debug7 from "debug";
|
|
6778
6773
|
|
|
6779
6774
|
// src/utils/presentationDefinition/MappingUtils.ts
|
|
6775
|
+
import { DcqlQuery } from "dcql";
|
|
6780
6776
|
import * as blakepkg from "blakejs";
|
|
6781
6777
|
var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
|
|
6782
6778
|
const result = {
|
|
@@ -6787,7 +6783,12 @@ var presentationDefinitionItemFrom = /* @__PURE__ */ __name((entity) => {
|
|
|
6787
6783
|
name: entity.name,
|
|
6788
6784
|
purpose: entity.purpose,
|
|
6789
6785
|
definitionPayload: JSON.parse(entity.definitionPayload),
|
|
6790
|
-
|
|
6786
|
+
...entity.dcqlPayload && {
|
|
6787
|
+
dcqlPayload: {
|
|
6788
|
+
queryId: entity.definitionId,
|
|
6789
|
+
dcqlQuery: DcqlQuery.parse(JSON.parse(entity.dcqlPayload))
|
|
6790
|
+
}
|
|
6791
|
+
},
|
|
6791
6792
|
createdAt: entity.createdAt,
|
|
6792
6793
|
lastUpdatedAt: entity.lastUpdatedAt
|
|
6793
6794
|
};
|
|
@@ -6800,8 +6801,12 @@ var presentationDefinitionEntityItemFrom = /* @__PURE__ */ __name((item) => {
|
|
|
6800
6801
|
entity.version = item.version;
|
|
6801
6802
|
entity.name = item.name;
|
|
6802
6803
|
entity.purpose = item.purpose;
|
|
6803
|
-
|
|
6804
|
-
|
|
6804
|
+
if (item.definitionPayload) {
|
|
6805
|
+
entity.definitionPayload = JSON.stringify(item.definitionPayload);
|
|
6806
|
+
}
|
|
6807
|
+
if (item.dcqlPayload) {
|
|
6808
|
+
entity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
|
|
6809
|
+
}
|
|
6805
6810
|
return entity;
|
|
6806
6811
|
}, "presentationDefinitionEntityItemFrom");
|
|
6807
6812
|
function hashPayload(payload) {
|
|
@@ -6809,13 +6814,24 @@ function hashPayload(payload) {
|
|
|
6809
6814
|
}
|
|
6810
6815
|
__name(hashPayload, "hashPayload");
|
|
6811
6816
|
function isPresentationDefinitionEqual(base, compare) {
|
|
6812
|
-
if (base.definitionId !== compare.definitionId || base.tenantId
|
|
6817
|
+
if (base.definitionId !== compare.definitionId || base.tenantId !== compare.tenantId || base.version !== compare.version || base.name !== compare.name || base.purpose !== compare.purpose) {
|
|
6818
|
+
return false;
|
|
6819
|
+
}
|
|
6820
|
+
if (base.dcqlPayload && compare.dcqlPayload) {
|
|
6821
|
+
if (hashPayload(base.dcqlPayload) !== hashPayload(compare.dcqlPayload)) {
|
|
6822
|
+
return false;
|
|
6823
|
+
}
|
|
6824
|
+
} else if (base.dcqlPayload || compare.dcqlPayload) {
|
|
6813
6825
|
return false;
|
|
6814
6826
|
}
|
|
6815
6827
|
if (base.definitionPayload && compare.definitionPayload) {
|
|
6816
|
-
|
|
6828
|
+
if (hashPayload(base.definitionPayload) !== hashPayload(compare.definitionPayload)) {
|
|
6829
|
+
return false;
|
|
6830
|
+
}
|
|
6831
|
+
} else if (base.definitionPayload || compare.definitionPayload) {
|
|
6832
|
+
return false;
|
|
6817
6833
|
}
|
|
6818
|
-
return
|
|
6834
|
+
return true;
|
|
6819
6835
|
}
|
|
6820
6836
|
__name(isPresentationDefinitionEqual, "isPresentationDefinitionEqual");
|
|
6821
6837
|
|
|
@@ -6904,7 +6920,12 @@ var PDStore = class extends AbstractPDStore {
|
|
|
6904
6920
|
updatedEntity.version = item.version;
|
|
6905
6921
|
updatedEntity.name = item.name;
|
|
6906
6922
|
updatedEntity.purpose = item.purpose;
|
|
6907
|
-
|
|
6923
|
+
if (item.definitionPayload) {
|
|
6924
|
+
updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload);
|
|
6925
|
+
}
|
|
6926
|
+
if (item.dcqlPayload) {
|
|
6927
|
+
updatedEntity.dcqlPayload = JSON.stringify(item.dcqlPayload.dcqlQuery);
|
|
6928
|
+
}
|
|
6908
6929
|
debug7("Updating presentation definition entity", updatedEntity);
|
|
6909
6930
|
const updateResult = await pdRepository.save(updatedEntity, {
|
|
6910
6931
|
transaction: true
|
|
@@ -7140,9 +7161,120 @@ var CreateContacts1659463079429 = class {
|
|
|
7140
7161
|
}
|
|
7141
7162
|
};
|
|
7142
7163
|
|
|
7143
|
-
// src/migrations/generic/
|
|
7164
|
+
// src/migrations/generic/10-CreatePresentationDefinitions.ts
|
|
7144
7165
|
import Debug9 from "debug";
|
|
7145
7166
|
|
|
7167
|
+
// src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts
|
|
7168
|
+
var CreatePresentationDefinitions1716475165345 = class {
|
|
7169
|
+
static {
|
|
7170
|
+
__name(this, "CreatePresentationDefinitions1716475165345");
|
|
7171
|
+
}
|
|
7172
|
+
name = "CreatePresentationDefinitions1716475165345";
|
|
7173
|
+
async up(queryRunner) {
|
|
7174
|
+
await queryRunner.query(`
|
|
7175
|
+
CREATE TABLE "PresentationDefinitionItem" (
|
|
7176
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
7177
|
+
"tenant_id" TEXT,
|
|
7178
|
+
"definition_id" TEXT NOT NULL,
|
|
7179
|
+
"name" TEXT,
|
|
7180
|
+
"version" TEXT NOT NULL,
|
|
7181
|
+
"purpose" TEXT,
|
|
7182
|
+
"definition_payload" TEXT NOT NULL,
|
|
7183
|
+
"dcql_payload" TEXT,
|
|
7184
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
7185
|
+
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
7186
|
+
CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
|
|
7187
|
+
`);
|
|
7188
|
+
}
|
|
7189
|
+
async down(queryRunner) {
|
|
7190
|
+
await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
|
|
7191
|
+
}
|
|
7192
|
+
};
|
|
7193
|
+
|
|
7194
|
+
// src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts
|
|
7195
|
+
var CreatePresentationDefinitions1716475165344 = class {
|
|
7196
|
+
static {
|
|
7197
|
+
__name(this, "CreatePresentationDefinitions1716475165344");
|
|
7198
|
+
}
|
|
7199
|
+
name = "CreatePresentationDefinitions1716475165344";
|
|
7200
|
+
async up(queryRunner) {
|
|
7201
|
+
await queryRunner.query(`CREATE TABLE "PresentationDefinitionItem" (
|
|
7202
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
7203
|
+
"tenant_id" varchar,
|
|
7204
|
+
"definition_id" varchar NOT NULL,
|
|
7205
|
+
"name" varchar,
|
|
7206
|
+
"version" varchar NOT NULL,
|
|
7207
|
+
"purpose" varchar,
|
|
7208
|
+
"definition_payload" varchar NOT NULL,
|
|
7209
|
+
"dcql_payload" varchar,
|
|
7210
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7211
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
7212
|
+
}
|
|
7213
|
+
async down(queryRunner) {
|
|
7214
|
+
await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
|
|
7215
|
+
}
|
|
7216
|
+
};
|
|
7217
|
+
|
|
7218
|
+
// src/migrations/generic/10-CreatePresentationDefinitions.ts
|
|
7219
|
+
var debug9 = Debug9("sphereon:ssi-sdk:migrations");
|
|
7220
|
+
var CreatePresentationDefinitions1716533767523 = class {
|
|
7221
|
+
static {
|
|
7222
|
+
__name(this, "CreatePresentationDefinitions1716533767523");
|
|
7223
|
+
}
|
|
7224
|
+
name = "CreatePresentationDefinitionItems1716533767523";
|
|
7225
|
+
async up(queryRunner) {
|
|
7226
|
+
debug9("migration: creating machine state tables");
|
|
7227
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
7228
|
+
switch (dbType) {
|
|
7229
|
+
case "postgres": {
|
|
7230
|
+
debug9("using postgres migration file");
|
|
7231
|
+
const mig = new CreatePresentationDefinitions1716475165345();
|
|
7232
|
+
await mig.up(queryRunner);
|
|
7233
|
+
debug9("Migration statements executed");
|
|
7234
|
+
return;
|
|
7235
|
+
}
|
|
7236
|
+
case "sqlite":
|
|
7237
|
+
case "expo":
|
|
7238
|
+
case "react-native": {
|
|
7239
|
+
debug9("using sqlite/react-native migration file");
|
|
7240
|
+
const mig = new CreatePresentationDefinitions1716475165344();
|
|
7241
|
+
await mig.up(queryRunner);
|
|
7242
|
+
debug9("Migration statements executed");
|
|
7243
|
+
return;
|
|
7244
|
+
}
|
|
7245
|
+
default:
|
|
7246
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7247
|
+
}
|
|
7248
|
+
}
|
|
7249
|
+
async down(queryRunner) {
|
|
7250
|
+
debug9("migration: reverting machine state tables");
|
|
7251
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
7252
|
+
switch (dbType) {
|
|
7253
|
+
case "postgres": {
|
|
7254
|
+
debug9("using postgres migration file");
|
|
7255
|
+
const mig = new CreatePresentationDefinitions1716475165345();
|
|
7256
|
+
await mig.down(queryRunner);
|
|
7257
|
+
debug9("Migration statements executed");
|
|
7258
|
+
return;
|
|
7259
|
+
}
|
|
7260
|
+
case "sqlite":
|
|
7261
|
+
case "expo":
|
|
7262
|
+
case "react-native": {
|
|
7263
|
+
debug9("using sqlite/react-native migration file");
|
|
7264
|
+
const mig = new CreatePresentationDefinitions1716475165344();
|
|
7265
|
+
await mig.down(queryRunner);
|
|
7266
|
+
debug9("Migration statements executed");
|
|
7267
|
+
return;
|
|
7268
|
+
}
|
|
7269
|
+
default:
|
|
7270
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7273
|
+
};
|
|
7274
|
+
|
|
7275
|
+
// src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
|
|
7276
|
+
import Debug10 from "debug";
|
|
7277
|
+
|
|
7146
7278
|
// src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts
|
|
7147
7279
|
import { enablePostgresUuidExtension as enablePostgresUuidExtension2 } from "@sphereon/ssi-sdk.core";
|
|
7148
7280
|
var CreateIssuanceBranding1685628974232 = class {
|
|
@@ -7279,31 +7411,105 @@ var CreateIssuanceBranding1685628973231 = class {
|
|
|
7279
7411
|
}
|
|
7280
7412
|
};
|
|
7281
7413
|
|
|
7282
|
-
// src/migrations/
|
|
7283
|
-
var
|
|
7284
|
-
var CreateIssuanceBranding1659463079429 = class {
|
|
7414
|
+
// src/migrations/postgres/1741895822987-FixCredentialClaimsReferencesUuid.ts
|
|
7415
|
+
var FixCredentialClaimsReferencesUuidPG1741895822987 = class {
|
|
7285
7416
|
static {
|
|
7286
|
-
__name(this, "
|
|
7417
|
+
__name(this, "FixCredentialClaimsReferencesUuidPG1741895822987");
|
|
7287
7418
|
}
|
|
7288
|
-
name = "
|
|
7419
|
+
name = "FixCredentialClaimsReferencesUuid1741895822987";
|
|
7420
|
+
async up(queryRunner) {
|
|
7421
|
+
await queryRunner.query(`
|
|
7422
|
+
ALTER TABLE "CredentialClaims"
|
|
7423
|
+
ALTER COLUMN "credentialLocaleBrandingId" TYPE uuid USING "credentialLocaleBrandingId"::uuid;
|
|
7424
|
+
`);
|
|
7425
|
+
}
|
|
7426
|
+
async down(queryRunner) {
|
|
7427
|
+
await queryRunner.query(`
|
|
7428
|
+
ALTER TABLE "CredentialClaims"
|
|
7429
|
+
ALTER COLUMN "credentialLocaleBrandingId" TYPE character varying USING "credentialLocaleBrandingId"::text;
|
|
7430
|
+
`);
|
|
7431
|
+
}
|
|
7432
|
+
};
|
|
7433
|
+
|
|
7434
|
+
// src/migrations/sqlite/1741895822987-FixCredentialClaimsReferencesUuid.ts
|
|
7435
|
+
var FixCredentialClaimsReferencesUuidSqlite1741895822987 = class {
|
|
7436
|
+
static {
|
|
7437
|
+
__name(this, "FixCredentialClaimsReferencesUuidSqlite1741895822987");
|
|
7438
|
+
}
|
|
7439
|
+
name = "FixCredentialClaimsReferencesUuid1741895822987";
|
|
7440
|
+
async up(queryRunner) {
|
|
7441
|
+
await queryRunner.query(`
|
|
7442
|
+
CREATE TABLE "CredentialClaims_new"
|
|
7443
|
+
(
|
|
7444
|
+
"id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
|
|
7445
|
+
"key" character varying(255) NOT NULL,
|
|
7446
|
+
"name" character varying(255) NOT NULL,
|
|
7447
|
+
"credentialLocaleBrandingId" uuid,
|
|
7448
|
+
CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
|
|
7449
|
+
)
|
|
7450
|
+
`);
|
|
7451
|
+
await queryRunner.query(`
|
|
7452
|
+
INSERT INTO "CredentialClaims_new" ("id", "key", "name", "credentialLocaleBrandingId")
|
|
7453
|
+
SELECT "id", "key", "name", "credentialLocaleBrandingId"
|
|
7454
|
+
FROM "CredentialClaims"
|
|
7455
|
+
`);
|
|
7456
|
+
await queryRunner.query(`DROP TABLE "CredentialClaims"`);
|
|
7457
|
+
await queryRunner.query(`ALTER TABLE "CredentialClaims_new" RENAME TO "CredentialClaims"`);
|
|
7458
|
+
await queryRunner.query(`
|
|
7459
|
+
CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
|
|
7460
|
+
ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
|
|
7461
|
+
`);
|
|
7462
|
+
}
|
|
7463
|
+
async down(queryRunner) {
|
|
7464
|
+
await queryRunner.query(`
|
|
7465
|
+
CREATE TABLE "CredentialClaims_old"
|
|
7466
|
+
(
|
|
7467
|
+
"id" uuid NOT NULL DEFAULT (lower(hex(randomblob(16)))),
|
|
7468
|
+
"key" character varying(255) NOT NULL,
|
|
7469
|
+
"name" character varying(255) NOT NULL,
|
|
7470
|
+
"credentialLocaleBrandingId" character varying,
|
|
7471
|
+
CONSTRAINT "PK_CredentialClaims_id" PRIMARY KEY ("id")
|
|
7472
|
+
)
|
|
7473
|
+
`);
|
|
7474
|
+
await queryRunner.query(`
|
|
7475
|
+
INSERT INTO "CredentialClaims_old" ("id", "key", "name", "credentialLocaleBrandingId")
|
|
7476
|
+
SELECT "id", "key", "name", "credentialLocaleBrandingId"
|
|
7477
|
+
FROM "CredentialClaims"
|
|
7478
|
+
`);
|
|
7479
|
+
await queryRunner.query(`DROP TABLE "CredentialClaims"`);
|
|
7480
|
+
await queryRunner.query(`ALTER TABLE "CredentialClaims_old" RENAME TO "CredentialClaims"`);
|
|
7481
|
+
await queryRunner.query(`
|
|
7482
|
+
CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
|
|
7483
|
+
ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
|
|
7484
|
+
`);
|
|
7485
|
+
}
|
|
7486
|
+
};
|
|
7487
|
+
|
|
7488
|
+
// src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts
|
|
7489
|
+
var debug10 = Debug10("sphereon:ssi-sdk:migrations");
|
|
7490
|
+
var FixCredentialClaimsReferencesUuid1741895822987 = class {
|
|
7491
|
+
static {
|
|
7492
|
+
__name(this, "FixCredentialClaimsReferencesUuid1741895822987");
|
|
7493
|
+
}
|
|
7494
|
+
name = "FixCredentialClaimsReferenceUuid1741895822987";
|
|
7289
7495
|
async up(queryRunner) {
|
|
7290
|
-
|
|
7496
|
+
debug10("migration: creating issuance branding uuid problem");
|
|
7291
7497
|
const dbType = queryRunner.connection.driver.options.type;
|
|
7292
7498
|
switch (dbType) {
|
|
7293
7499
|
case "postgres": {
|
|
7294
|
-
|
|
7295
|
-
const mig = new
|
|
7500
|
+
debug10("using postgres migration file");
|
|
7501
|
+
const mig = new FixCredentialClaimsReferencesUuidPG1741895822987();
|
|
7296
7502
|
await mig.up(queryRunner);
|
|
7297
|
-
|
|
7503
|
+
debug10("Migration statements executed");
|
|
7298
7504
|
return;
|
|
7299
7505
|
}
|
|
7300
7506
|
case "sqlite":
|
|
7301
7507
|
case "expo":
|
|
7302
7508
|
case "react-native": {
|
|
7303
|
-
|
|
7304
|
-
const mig = new
|
|
7509
|
+
debug10("using sqlite/react-native migration file");
|
|
7510
|
+
const mig = new FixCredentialClaimsReferencesUuidSqlite1741895822987();
|
|
7305
7511
|
await mig.up(queryRunner);
|
|
7306
|
-
|
|
7512
|
+
debug10("Migration statements executed");
|
|
7307
7513
|
return;
|
|
7308
7514
|
}
|
|
7309
7515
|
default:
|
|
@@ -7311,23 +7517,23 @@ var CreateIssuanceBranding1659463079429 = class {
|
|
|
7311
7517
|
}
|
|
7312
7518
|
}
|
|
7313
7519
|
async down(queryRunner) {
|
|
7314
|
-
|
|
7520
|
+
debug10("migration: reverting issuance branding uuid migration");
|
|
7315
7521
|
const dbType = queryRunner.connection.driver.options.type;
|
|
7316
7522
|
switch (dbType) {
|
|
7317
7523
|
case "postgres": {
|
|
7318
|
-
|
|
7524
|
+
debug10("using postgres migration file");
|
|
7319
7525
|
const mig = new CreateIssuanceBranding1685628974232();
|
|
7320
7526
|
await mig.down(queryRunner);
|
|
7321
|
-
|
|
7527
|
+
debug10("Migration statements executed");
|
|
7322
7528
|
return;
|
|
7323
7529
|
}
|
|
7324
7530
|
case "sqlite":
|
|
7325
7531
|
case "expo":
|
|
7326
7532
|
case "react-native": {
|
|
7327
|
-
|
|
7533
|
+
debug10("using sqlite/react-native migration file");
|
|
7328
7534
|
const mig = new CreateIssuanceBranding1685628973231();
|
|
7329
7535
|
await mig.down(queryRunner);
|
|
7330
|
-
|
|
7536
|
+
debug10("Migration statements executed");
|
|
7331
7537
|
return;
|
|
7332
7538
|
}
|
|
7333
7539
|
default:
|
|
@@ -7336,658 +7542,364 @@ var CreateIssuanceBranding1659463079429 = class {
|
|
|
7336
7542
|
}
|
|
7337
7543
|
};
|
|
7338
7544
|
|
|
7339
|
-
// src/migrations/generic/
|
|
7340
|
-
import
|
|
7545
|
+
// src/migrations/generic/12-CreateBitstringStatusList.ts
|
|
7546
|
+
import Debug11 from "debug";
|
|
7341
7547
|
|
|
7342
|
-
// src/migrations/
|
|
7343
|
-
var
|
|
7548
|
+
// src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts
|
|
7549
|
+
var AddBitstringStatusListEnumPG1741895823000 = class {
|
|
7344
7550
|
static {
|
|
7345
|
-
__name(this, "
|
|
7551
|
+
__name(this, "AddBitstringStatusListEnumPG1741895823000");
|
|
7346
7552
|
}
|
|
7347
|
-
name = "
|
|
7553
|
+
name = "AddBitstringStatusListEnum1741895823000";
|
|
7348
7554
|
async up(queryRunner) {
|
|
7349
|
-
await queryRunner.
|
|
7350
|
-
await queryRunner.query(`
|
|
7351
|
-
await queryRunner.
|
|
7352
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
7353
|
-
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
|
|
7354
|
-
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
|
|
7355
|
-
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
7356
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
7357
|
-
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`);
|
|
7358
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
|
|
7359
|
-
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
7360
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
7361
|
-
await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
|
|
7362
|
-
await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
|
|
7363
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
7364
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
7365
|
-
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
|
|
7366
|
-
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
|
|
7367
|
-
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
7368
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
7369
|
-
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identity_id"))`);
|
|
7370
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
|
|
7371
|
-
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
7372
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
7373
|
-
await queryRunner.query(`CREATE TABLE "PartyType" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('naturalPerson','organization') ) NOT NULL, "origin" varchar CHECK( "origin" IN ('INTERNAL', 'EXTERNAL') ) NOT NULL, "name" varchar(255) NOT NULL, "description" varchar(255), "tenant_id" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"))`);
|
|
7374
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
|
|
7375
|
-
await queryRunner.query(`CREATE TABLE "BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"))`);
|
|
7376
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
7377
|
-
await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
7378
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
7379
|
-
await queryRunner.query(`CREATE TABLE "Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL)`);
|
|
7380
|
-
await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"))`);
|
|
7381
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
7382
|
-
await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identity_id" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7383
|
-
await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
|
|
7384
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
7385
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
7386
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
7387
|
-
await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7388
|
-
await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
|
|
7389
|
-
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
7390
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
|
|
7391
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
7392
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
7393
|
-
await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7394
|
-
await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
|
|
7395
|
-
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
7396
|
-
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
|
|
7397
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
7398
|
-
await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7399
|
-
await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "street_name" varchar(255) NOT NULL, "street_number" varchar(255) NOT NULL, "postal_code" varchar(255) NOT NULL, "city_name" varchar(255) NOT NULL, "province_name" varchar(255) NOT NULL, "country_code" varchar(2) NOT NULL, "building_name" varchar(255), "partyId" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7400
|
-
await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
|
7401
|
-
await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
|
|
7402
|
-
await queryRunner.query(`DROP TABLE "Party"`);
|
|
7403
|
-
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
|
|
7404
|
-
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"), CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7405
|
-
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "partyId" FROM "Identity"`);
|
|
7406
|
-
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
7407
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
7408
|
-
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identity_id" UNIQUE ("identity_id"), CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7409
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
|
|
7410
|
-
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
7411
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
7412
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
7413
|
-
await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7414
|
-
await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
7415
|
-
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
7416
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
|
|
7417
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
7418
|
-
await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
|
|
7419
|
-
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
|
|
7420
|
-
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
|
|
7421
|
-
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
|
|
7422
|
-
await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
|
|
7423
|
-
await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
|
|
7424
|
-
await queryRunner.query(`DROP TABLE "Contact"`);
|
|
7425
|
-
}
|
|
7426
|
-
async down(queryRunner) {
|
|
7427
|
-
await queryRunner.query(`CREATE TABLE "Contact" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "name" varchar(255), "alias" varchar(255))`);
|
|
7428
|
-
await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
|
|
7429
|
-
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
7430
|
-
await queryRunner.query(`DROP TABLE "Party"`);
|
|
7431
|
-
await queryRunner.query(`CREATE TABLE "BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connectionId" varchar)`);
|
|
7432
|
-
await queryRunner.query(`INSERT INTO "BaseConfigEntity"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
7433
|
-
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
7434
|
-
await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
|
7435
|
-
await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
|
|
7436
|
-
await queryRunner.query(`DROP TABLE "Party"`);
|
|
7437
|
-
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
|
|
7438
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
7439
|
-
await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7440
|
-
await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
|
|
7441
|
-
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
7442
|
-
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
|
|
7443
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
7444
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
7445
|
-
await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7446
|
-
await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
|
|
7447
|
-
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
7448
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
|
|
7449
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
7450
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
7451
|
-
await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
7452
|
-
await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
7453
|
-
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
7454
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
|
|
7455
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
7456
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
|
|
7457
|
-
await queryRunner.query(`DROP TABLE "PartyType"`);
|
|
7458
|
-
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
7459
|
-
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
7460
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
7461
|
-
await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
|
|
7462
|
-
await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
|
|
7463
|
-
}
|
|
7464
|
-
};
|
|
7465
|
-
|
|
7466
|
-
// src/migrations/postgres/1690925872592-CreateContacts.ts
|
|
7467
|
-
import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
|
|
7468
|
-
var CreateContacts1690925872592 = class {
|
|
7469
|
-
static {
|
|
7470
|
-
__name(this, "CreateContacts1690925872592");
|
|
7471
|
-
}
|
|
7472
|
-
name = "CreateContacts1690925872592";
|
|
7473
|
-
async up(queryRunner) {
|
|
7474
|
-
await enablePostgresUuidExtension3(queryRunner);
|
|
7475
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
|
|
7476
|
-
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
|
|
7477
|
-
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
|
|
7478
|
-
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
|
|
7479
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
|
|
7480
|
-
await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
|
|
7481
|
-
await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
|
|
7482
|
-
await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
|
|
7483
|
-
await queryRunner.query(`CREATE TABLE "PartyType" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."PartyType_type_enum" NOT NULL, "origin" "public"."PartyOrigin_type_enum" NOT NULL, "name" character varying(255) NOT NULL, "description" character varying(255), "tenant_id" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"), CONSTRAINT "PK_PartyType_id" PRIMARY KEY ("id"))`);
|
|
7484
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
|
|
7485
|
-
await queryRunner.query(`CREATE TABLE "BaseContact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "legal_name" character varying(255), "display_name" character varying(255), "first_name" character varying(255), "middle_name" character varying(255), "last_name" character varying(255), "type" character varying NOT NULL, "party_id" uuid, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "PK_BaseContact_id" PRIMARY KEY ("id"))`);
|
|
7486
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
7487
|
-
await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "left_id" uuid NOT NULL, "right_id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PartyRelationship_id" PRIMARY KEY ("id"))`);
|
|
7488
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
7489
|
-
await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "electronic_address" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "partyId" uuid, CONSTRAINT "PK_ElectronicAddress_id" PRIMARY KEY ("id"))`);
|
|
7490
|
-
await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "street_name" character varying(255) NOT NULL, "street_number" character varying(255) NOT NULL, "postal_code" character varying(255) NOT NULL, "city_name" character varying(255) NOT NULL, "province_name" character varying(255) NOT NULL, "country_code" character varying(2) NOT NULL, "building_name" character varying(255), "partyId" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PhysicalAddress_id" PRIMARY KEY ("id"))`);
|
|
7491
|
-
await queryRunner.query(`CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`);
|
|
7492
|
-
await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "identifier" character varying(255), "redirect_url" character varying(255), "session_id" character varying(255), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" character varying NOT NULL, "connection_id" uuid, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "PK_BaseConfig_id" PRIMARY KEY ("id"))`);
|
|
7493
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
7494
|
-
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
|
|
7495
|
-
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
|
|
7496
|
-
await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
|
|
7497
|
-
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
|
|
7498
|
-
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
|
|
7499
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7500
|
-
await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7501
|
-
await queryRunner.query(`ALTER TABLE "BaseContact" ADD CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7502
|
-
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7503
|
-
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7504
|
-
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7505
|
-
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7506
|
-
await queryRunner.query(`ALTER TABLE "Party" ADD CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
7507
|
-
await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7508
|
-
await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7509
|
-
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7510
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
|
|
7511
|
-
await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
|
|
7512
|
-
await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
|
|
7513
|
-
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
|
|
7514
|
-
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
|
|
7515
|
-
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
|
|
7516
|
-
await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
|
|
7517
|
-
await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
|
|
7518
|
-
await queryRunner.query(`DROP TABLE "Contact"`);
|
|
7519
|
-
}
|
|
7520
|
-
async down(queryRunner) {
|
|
7521
|
-
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
|
|
7522
|
-
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
|
|
7523
|
-
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
|
|
7524
|
-
await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
|
|
7525
|
-
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
|
|
7526
|
-
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
|
|
7527
|
-
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
|
|
7528
|
-
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
|
|
7529
|
-
await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
|
|
7530
|
-
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
|
|
7531
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
|
|
7532
|
-
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
|
|
7533
|
-
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
|
|
7534
|
-
await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
|
|
7535
|
-
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
|
|
7536
|
-
await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
|
|
7537
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
|
|
7538
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
7539
|
-
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
7540
|
-
await queryRunner.query(`DROP TABLE "Party"`);
|
|
7541
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
7542
|
-
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
7543
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
7544
|
-
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
7545
|
-
await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
|
|
7546
|
-
await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
|
|
7547
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
|
|
7548
|
-
await queryRunner.query(`DROP TABLE "PartyType"`);
|
|
7549
|
-
await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
|
|
7550
|
-
await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
|
|
7551
|
-
await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7552
|
-
await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7553
|
-
await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7554
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
7555
|
-
await queryRunner.query(`CREATE TABLE "Contact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying(255), "alias" character varying(255), CONSTRAINT "PK_Contact_id" PRIMARY KEY ("id"))`);
|
|
7556
|
-
await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
|
|
7557
|
-
}
|
|
7558
|
-
};
|
|
7559
|
-
|
|
7560
|
-
// src/migrations/generic/3-CreateContacts.ts
|
|
7561
|
-
var debug10 = Debug10("sphereon:ssi-sdk:migrations");
|
|
7562
|
-
var CreateContacts1690925872318 = class {
|
|
7563
|
-
static {
|
|
7564
|
-
__name(this, "CreateContacts1690925872318");
|
|
7565
|
-
}
|
|
7566
|
-
name = "CreateContacts1690925872318";
|
|
7567
|
-
async up(queryRunner) {
|
|
7568
|
-
debug10("migration: creating contacts tables");
|
|
7569
|
-
const dbType = queryRunner.connection.driver.options.type;
|
|
7570
|
-
switch (dbType) {
|
|
7571
|
-
case "postgres": {
|
|
7572
|
-
debug10("using postgres migration file");
|
|
7573
|
-
const mig = new CreateContacts1690925872592();
|
|
7574
|
-
await mig.up(queryRunner);
|
|
7575
|
-
debug10("Migration statements executed");
|
|
7576
|
-
return;
|
|
7577
|
-
}
|
|
7578
|
-
case "sqlite":
|
|
7579
|
-
case "expo":
|
|
7580
|
-
case "react-native": {
|
|
7581
|
-
debug10("using sqlite/react-native migration file");
|
|
7582
|
-
const mig = new CreateContacts1690925872693();
|
|
7583
|
-
await mig.up(queryRunner);
|
|
7584
|
-
debug10("Migration statements executed");
|
|
7585
|
-
return;
|
|
7586
|
-
}
|
|
7587
|
-
default:
|
|
7588
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7589
|
-
}
|
|
7555
|
+
await queryRunner.startTransaction();
|
|
7556
|
+
await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`);
|
|
7557
|
+
await queryRunner.commitTransaction();
|
|
7590
7558
|
}
|
|
7559
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7591
7560
|
async down(queryRunner) {
|
|
7592
|
-
debug10("migration: reverting contacts tables");
|
|
7593
|
-
const dbType = queryRunner.connection.driver.options.type;
|
|
7594
|
-
switch (dbType) {
|
|
7595
|
-
case "postgres": {
|
|
7596
|
-
debug10("using postgres migration file");
|
|
7597
|
-
const mig = new CreateContacts1690925872592();
|
|
7598
|
-
await mig.down(queryRunner);
|
|
7599
|
-
debug10("Migration statements executed");
|
|
7600
|
-
return;
|
|
7601
|
-
}
|
|
7602
|
-
case "sqlite":
|
|
7603
|
-
case "expo":
|
|
7604
|
-
case "react-native": {
|
|
7605
|
-
debug10("using sqlite/react-native migration file");
|
|
7606
|
-
const mig = new CreateContacts1690925872693();
|
|
7607
|
-
await mig.down(queryRunner);
|
|
7608
|
-
debug10("Migration statements executed");
|
|
7609
|
-
return;
|
|
7610
|
-
}
|
|
7611
|
-
default:
|
|
7612
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7613
|
-
}
|
|
7614
7561
|
}
|
|
7615
7562
|
};
|
|
7616
|
-
|
|
7617
|
-
// src/migrations/generic/4-CreateStatusList.ts
|
|
7618
|
-
import Debug11 from "debug";
|
|
7619
|
-
|
|
7620
|
-
// src/migrations/postgres/1693866470001-CreateStatusList.ts
|
|
7621
|
-
var CreateStatusList1693866470001 = class {
|
|
7622
|
-
static {
|
|
7623
|
-
__name(this, "CreateStatusList1693866470001");
|
|
7624
|
-
}
|
|
7625
|
-
name = "CreateStatusList1693866470001";
|
|
7626
|
-
async up(queryRunner) {
|
|
7627
|
-
await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
|
|
7628
|
-
await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
|
|
7629
|
-
await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
|
|
7630
|
-
await queryRunner.query(`CREATE TABLE "StatusListEntry"
|
|
7631
|
-
(
|
|
7632
|
-
"statusListId" character varying NOT NULL,
|
|
7633
|
-
"statusListIndex" integer NOT NULL,
|
|
7634
|
-
"credentialId" character varying,
|
|
7635
|
-
"credentialHash" character varying(128),
|
|
7636
|
-
"correlationId" character varying(255),
|
|
7637
|
-
"value" character varying(50),
|
|
7638
|
-
CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
|
|
7639
|
-
)`);
|
|
7640
|
-
await queryRunner.query(`CREATE TABLE "StatusList"
|
|
7641
|
-
(
|
|
7642
|
-
"id" character varying NOT NULL,
|
|
7643
|
-
"correlationId" character varying NOT NULL,
|
|
7644
|
-
"length" integer NOT NULL,
|
|
7645
|
-
"issuer" text NOT NULL,
|
|
7646
|
-
"type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
|
|
7647
|
-
"driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
|
|
7648
|
-
"credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
|
|
7649
|
-
"proofFormat" character varying NOT NULL DEFAULT 'lds',
|
|
7650
|
-
"indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
|
|
7651
|
-
"statusPurpose" character varying NOT NULL DEFAULT 'revocation',
|
|
7652
|
-
"statusListCredential" text,
|
|
7653
|
-
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
|
|
7654
|
-
CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
|
|
7655
|
-
)`);
|
|
7656
|
-
await queryRunner.query(`ALTER TABLE "StatusListEntry"
|
|
7657
|
-
ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
7658
|
-
}
|
|
7659
|
-
async down(queryRunner) {
|
|
7660
|
-
await queryRunner.query(`ALTER TABLE "StatusListEntry"
|
|
7661
|
-
DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
|
|
7662
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
7663
|
-
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
7664
|
-
await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
|
|
7665
|
-
await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
|
|
7666
|
-
await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
|
|
7667
|
-
}
|
|
7668
|
-
};
|
|
7669
|
-
|
|
7670
|
-
// src/migrations/sqlite/1693866470000-CreateStatusList.ts
|
|
7671
|
-
var CreateStatusList1693866470002 = class {
|
|
7672
|
-
static {
|
|
7673
|
-
__name(this, "CreateStatusList1693866470002");
|
|
7674
|
-
}
|
|
7675
|
-
name = "CreateStatusList1693866470002";
|
|
7676
|
-
async up(queryRunner) {
|
|
7677
|
-
await queryRunner.query(`CREATE TABLE "StatusListEntry"
|
|
7678
|
-
(
|
|
7679
|
-
"statusListId" varchar NOT NULL,
|
|
7680
|
-
"statusListIndex" integer NOT NULL,
|
|
7681
|
-
"credentialId" varchar,
|
|
7682
|
-
"credentialHash" varchar(128),
|
|
7683
|
-
"correlationId" varchar(255),
|
|
7684
|
-
"value" varchar(50),
|
|
7685
|
-
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
7686
|
-
)`);
|
|
7687
|
-
await queryRunner.query(`CREATE TABLE "StatusList"
|
|
7688
|
-
(
|
|
7689
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
7690
|
-
"correlationId" varchar NOT NULL,
|
|
7691
|
-
"length" integer NOT NULL,
|
|
7692
|
-
"issuer" text NOT NULL,
|
|
7693
|
-
"type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
7694
|
-
"driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
|
|
7695
|
-
'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
7696
|
-
"credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
7697
|
-
"proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
|
|
7698
|
-
"indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
|
|
7699
|
-
"statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
|
|
7700
|
-
"statusListCredential" text,
|
|
7701
|
-
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
7702
|
-
)`);
|
|
7703
|
-
await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
|
|
7704
|
-
(
|
|
7705
|
-
"statusListId" varchar NOT NULL,
|
|
7706
|
-
"statusListIndex" integer NOT NULL,
|
|
7707
|
-
"credentialId" varchar,
|
|
7708
|
-
"credentialHash" varchar(128),
|
|
7709
|
-
"correlationId" varchar(255),
|
|
7710
|
-
"value" varchar(50),
|
|
7711
|
-
CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
|
7712
|
-
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
7713
|
-
)`);
|
|
7714
|
-
await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
|
|
7715
|
-
"credentialHash", "correlationId", "value")
|
|
7716
|
-
SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
|
|
7717
|
-
FROM "StatusListEntry"`);
|
|
7718
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
7719
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
7720
|
-
}
|
|
7721
|
-
async down(queryRunner) {
|
|
7722
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
7723
|
-
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
7724
|
-
}
|
|
7725
|
-
};
|
|
7726
|
-
|
|
7727
|
-
// src/migrations/postgres/1737110469001-UpdateStatusList.ts
|
|
7728
|
-
var UpdateStatusList1737110469001 = class {
|
|
7563
|
+
var CreateBitstringStatusListPG1741895823000 = class {
|
|
7729
7564
|
static {
|
|
7730
|
-
__name(this, "
|
|
7565
|
+
__name(this, "CreateBitstringStatusListPG1741895823000");
|
|
7731
7566
|
}
|
|
7732
|
-
name = "
|
|
7567
|
+
name = "CreateBitstringStatusList1741895823000";
|
|
7733
7568
|
async up(queryRunner) {
|
|
7734
|
-
await queryRunner.query(`ALTER
|
|
7735
|
-
await queryRunner.query(`ALTER TABLE "StatusList"
|
|
7736
|
-
await queryRunner.query(`ALTER TABLE "StatusList"
|
|
7737
|
-
await queryRunner.query(`ALTER TABLE "StatusList"
|
|
7738
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD "
|
|
7569
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`);
|
|
7570
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`);
|
|
7571
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`);
|
|
7572
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`);
|
|
7573
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`);
|
|
7574
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "type" character varying NOT NULL DEFAULT 'StatusListEntryEntity'`);
|
|
7575
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`);
|
|
7576
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`);
|
|
7577
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`);
|
|
7578
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD CONSTRAINT "CHK_StatusListEntry_type" CHECK ("type" IN ('StatusListEntryEntity', 'bitstring'))`);
|
|
7739
7579
|
}
|
|
7740
7580
|
async down(queryRunner) {
|
|
7741
|
-
await queryRunner.query(`ALTER TABLE "
|
|
7581
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP CONSTRAINT "CHK_StatusListEntry_type"`);
|
|
7582
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusReference"`);
|
|
7583
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusMessage"`);
|
|
7584
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "bitsPerStatus"`);
|
|
7585
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "statusPurpose"`);
|
|
7586
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" DROP COLUMN "type"`);
|
|
7587
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`);
|
|
7588
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`);
|
|
7589
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`);
|
|
7590
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`);
|
|
7591
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`);
|
|
7742
7592
|
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
|
|
7743
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
|
|
7744
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
|
|
7745
7593
|
}
|
|
7746
7594
|
};
|
|
7747
7595
|
|
|
7748
|
-
// src/migrations/sqlite/
|
|
7749
|
-
var
|
|
7596
|
+
// src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts
|
|
7597
|
+
var CreateBitstringStatusListSqlite1741895823001 = class {
|
|
7750
7598
|
static {
|
|
7751
|
-
__name(this, "
|
|
7599
|
+
__name(this, "CreateBitstringStatusListSqlite1741895823001");
|
|
7752
7600
|
}
|
|
7753
|
-
name = "
|
|
7601
|
+
name = "CreateBitstringStatusList1741895823000";
|
|
7754
7602
|
async up(queryRunner) {
|
|
7755
|
-
await queryRunner.query(`
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7603
|
+
await queryRunner.query(`
|
|
7604
|
+
CREATE TABLE "temporary_StatusList" (
|
|
7605
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
7606
|
+
"correlationId" varchar NOT NULL,
|
|
7607
|
+
"length" integer NOT NULL,
|
|
7608
|
+
"issuer" text NOT NULL,
|
|
7609
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
7610
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
7611
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
7612
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
|
|
7613
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
7614
|
+
"statusPurpose" varchar,
|
|
7615
|
+
"statusListCredential" text,
|
|
7616
|
+
"expiresAt" datetime,
|
|
7617
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
7618
|
+
"ttl" integer,
|
|
7619
|
+
"validFrom" datetime,
|
|
7620
|
+
"validUntil" datetime,
|
|
7621
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
7622
|
+
)
|
|
7623
|
+
`);
|
|
7624
|
+
await queryRunner.query(`
|
|
7625
|
+
INSERT INTO "temporary_StatusList"(
|
|
7626
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
7627
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
7628
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
7629
|
+
)
|
|
7630
|
+
SELECT
|
|
7631
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
7632
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
7633
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
7634
|
+
FROM "StatusList"
|
|
7635
|
+
`);
|
|
7781
7636
|
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
7782
7637
|
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
7638
|
+
await queryRunner.query(`
|
|
7639
|
+
CREATE TABLE "temporary_StatusListEntry" (
|
|
7640
|
+
"statusListId" varchar NOT NULL,
|
|
7641
|
+
"statusListIndex" integer NOT NULL,
|
|
7642
|
+
"credentialId" text,
|
|
7643
|
+
"credentialHash" varchar(128),
|
|
7644
|
+
"correlationId" varchar(255),
|
|
7645
|
+
"value" varchar(50),
|
|
7646
|
+
"type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
|
|
7647
|
+
"statusPurpose" varchar,
|
|
7648
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
7649
|
+
"statusMessage" text,
|
|
7650
|
+
"statusReference" text,
|
|
7651
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
7652
|
+
)
|
|
7653
|
+
`);
|
|
7654
|
+
await queryRunner.query(`
|
|
7655
|
+
INSERT INTO "temporary_StatusListEntry"(
|
|
7656
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
7657
|
+
"correlationId", "value", "type"
|
|
7658
|
+
)
|
|
7659
|
+
SELECT
|
|
7660
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
7661
|
+
"correlationId", "value", 'StatusListEntryEntity'
|
|
7662
|
+
FROM "StatusListEntry"
|
|
7663
|
+
`);
|
|
7664
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
7665
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
7783
7666
|
}
|
|
7784
7667
|
async down(queryRunner) {
|
|
7785
7668
|
await queryRunner.query(`
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7669
|
+
CREATE TABLE "temporary_StatusListEntry" (
|
|
7670
|
+
"statusListId" varchar NOT NULL,
|
|
7671
|
+
"statusListIndex" integer NOT NULL,
|
|
7672
|
+
"credentialId" text,
|
|
7673
|
+
"credentialHash" varchar(128),
|
|
7674
|
+
"correlationId" varchar(255),
|
|
7675
|
+
"value" varchar(50),
|
|
7676
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
7677
|
+
)
|
|
7678
|
+
`);
|
|
7789
7679
|
await queryRunner.query(`
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7680
|
+
INSERT INTO "temporary_StatusListEntry"(
|
|
7681
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
7682
|
+
"correlationId", "value"
|
|
7683
|
+
)
|
|
7684
|
+
SELECT
|
|
7685
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
7686
|
+
"correlationId", "value"
|
|
7687
|
+
FROM "StatusListEntry"
|
|
7688
|
+
WHERE "type" = 'StatusListEntryEntity'
|
|
7689
|
+
`);
|
|
7690
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
7691
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
7692
|
+
await queryRunner.query(`
|
|
7693
|
+
CREATE TABLE "temporary_StatusList" (
|
|
7694
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
7695
|
+
"correlationId" varchar NOT NULL,
|
|
7696
|
+
"length" integer NOT NULL,
|
|
7697
|
+
"issuer" text NOT NULL,
|
|
7698
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
7699
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
7700
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
7701
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
|
|
7702
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
7703
|
+
"statusPurpose" varchar,
|
|
7704
|
+
"statusListCredential" text,
|
|
7705
|
+
"bitsPerStatus" integer,
|
|
7706
|
+
"expiresAt" datetime,
|
|
7707
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
7708
|
+
)
|
|
7709
|
+
`);
|
|
7710
|
+
await queryRunner.query(`
|
|
7711
|
+
INSERT INTO "temporary_StatusList"(
|
|
7712
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
7713
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
7714
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
7715
|
+
)
|
|
7716
|
+
SELECT
|
|
7717
|
+
"id", "correlationId", "length", "issuer",
|
|
7718
|
+
CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
7719
|
+
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
7720
|
+
"statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
|
|
7721
|
+
FROM "StatusList"
|
|
7722
|
+
`);
|
|
7818
7723
|
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
7819
7724
|
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
7820
7725
|
}
|
|
7821
7726
|
};
|
|
7822
7727
|
|
|
7823
|
-
// src/migrations/generic/
|
|
7728
|
+
// src/migrations/generic/12-CreateBitstringStatusList.ts
|
|
7824
7729
|
var debug11 = Debug11("sphereon:ssi-sdk:migrations");
|
|
7825
|
-
var
|
|
7730
|
+
var AddBitstringStatusListEnum1741895823000 = class {
|
|
7826
7731
|
static {
|
|
7827
|
-
__name(this, "
|
|
7732
|
+
__name(this, "AddBitstringStatusListEnum1741895823000");
|
|
7828
7733
|
}
|
|
7829
|
-
name = "
|
|
7734
|
+
name = "AddBitstringStatusListEnum1741895823000";
|
|
7830
7735
|
async up(queryRunner) {
|
|
7831
|
-
debug11("migration: creating
|
|
7736
|
+
debug11("migration: creating bitstring status list tables");
|
|
7832
7737
|
const dbType = queryRunner.connection.driver.options.type;
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7738
|
+
switch (dbType) {
|
|
7739
|
+
case "postgres": {
|
|
7740
|
+
const mig = new AddBitstringStatusListEnumPG1741895823000();
|
|
7741
|
+
await mig.up(queryRunner);
|
|
7742
|
+
return;
|
|
7743
|
+
}
|
|
7744
|
+
case "sqlite":
|
|
7745
|
+
case "expo":
|
|
7746
|
+
case "react-native": {
|
|
7747
|
+
return;
|
|
7748
|
+
}
|
|
7749
|
+
default:
|
|
7750
|
+
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
|
|
7751
|
+
}
|
|
7752
|
+
}
|
|
7753
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7754
|
+
async down(queryRunner) {
|
|
7755
|
+
}
|
|
7756
|
+
};
|
|
7757
|
+
var CreateBitstringStatusList1741895823000 = class {
|
|
7758
|
+
static {
|
|
7759
|
+
__name(this, "CreateBitstringStatusList1741895823000");
|
|
7760
|
+
}
|
|
7761
|
+
name = "CreateBitstringStatusList1741895823000";
|
|
7762
|
+
async up(queryRunner) {
|
|
7763
|
+
debug11("migration: creating bitstring status list tables");
|
|
7764
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
7765
|
+
switch (dbType) {
|
|
7766
|
+
case "postgres": {
|
|
7767
|
+
const mig = new CreateBitstringStatusListPG1741895823000();
|
|
7768
|
+
await mig.up(queryRunner);
|
|
7769
|
+
return;
|
|
7770
|
+
}
|
|
7771
|
+
case "sqlite":
|
|
7772
|
+
case "expo":
|
|
7773
|
+
case "react-native": {
|
|
7774
|
+
const mig = new CreateBitstringStatusListSqlite1741895823001();
|
|
7775
|
+
await mig.up(queryRunner);
|
|
7776
|
+
return;
|
|
7777
|
+
}
|
|
7778
|
+
default:
|
|
7779
|
+
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
|
|
7851
7780
|
}
|
|
7852
7781
|
}
|
|
7853
7782
|
async down(queryRunner) {
|
|
7854
|
-
debug11("migration:
|
|
7783
|
+
debug11("migration: dropping bitstring status list tables");
|
|
7855
7784
|
const dbType = queryRunner.connection.driver.options.type;
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
return down;
|
|
7872
|
-
} else {
|
|
7873
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7785
|
+
switch (dbType) {
|
|
7786
|
+
case "postgres": {
|
|
7787
|
+
const mig = new CreateBitstringStatusListPG1741895823000();
|
|
7788
|
+
await mig.down(queryRunner);
|
|
7789
|
+
return;
|
|
7790
|
+
}
|
|
7791
|
+
case "sqlite":
|
|
7792
|
+
case "expo":
|
|
7793
|
+
case "react-native": {
|
|
7794
|
+
const mig = new CreateBitstringStatusListSqlite1741895823001();
|
|
7795
|
+
await mig.down(queryRunner);
|
|
7796
|
+
return;
|
|
7797
|
+
}
|
|
7798
|
+
default:
|
|
7799
|
+
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
|
|
7874
7800
|
}
|
|
7875
7801
|
}
|
|
7876
7802
|
};
|
|
7877
7803
|
|
|
7878
|
-
// src/migrations/generic/
|
|
7804
|
+
// src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
|
|
7879
7805
|
import Debug12 from "debug";
|
|
7880
7806
|
|
|
7881
|
-
// src/migrations/
|
|
7882
|
-
var
|
|
7807
|
+
// src/migrations/postgres/1756975509000-UpdatePresentationDefinitionItemNullable.ts
|
|
7808
|
+
var UpdatePresentationDefinitionItemNullablePG1741895824000 = class {
|
|
7883
7809
|
static {
|
|
7884
|
-
__name(this, "
|
|
7810
|
+
__name(this, "UpdatePresentationDefinitionItemNullablePG1741895824000");
|
|
7885
7811
|
}
|
|
7886
|
-
name = "
|
|
7812
|
+
name = "UpdatePresentationDefinitionItemNullable1741895824000";
|
|
7887
7813
|
async up(queryRunner) {
|
|
7888
|
-
await queryRunner.query(`
|
|
7889
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
7890
|
-
"eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
|
|
7891
|
-
"timestamp" datetime NOT NULL,
|
|
7892
|
-
"level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
|
|
7893
|
-
"correlationId" varchar NOT NULL,
|
|
7894
|
-
"system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
|
|
7895
|
-
"subSystemType" varchar CHECK( "subSystemType" IN ('key','did_provider','did_resolver','oid4vp_op','oid4vci_client','siopv2_op','contact_manager','vc_issuer','vc_verifier','vc_persistence','transport','profile','api') ) NOT NULL,
|
|
7896
|
-
"actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
|
|
7897
|
-
"actionSubType" varchar NOT NULL,
|
|
7898
|
-
"initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
|
|
7899
|
-
"systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
|
|
7900
|
-
"systemCorrelationId" varchar,
|
|
7901
|
-
"systemAlias" varchar,
|
|
7902
|
-
"partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
|
|
7903
|
-
"partyCorrelationId" varchar,
|
|
7904
|
-
"partyAlias" varchar,
|
|
7905
|
-
"credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
|
|
7906
|
-
"credentialHash" varchar,
|
|
7907
|
-
"parentCredentialHash" varchar,
|
|
7908
|
-
"originalCredential" varchar,
|
|
7909
|
-
"sharePurpose" varchar,
|
|
7910
|
-
"description" varchar NOT NULL,
|
|
7911
|
-
"data" varchar,
|
|
7912
|
-
"diagnosticData" varchar,
|
|
7913
|
-
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7914
|
-
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
7814
|
+
await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" DROP NOT NULL`);
|
|
7915
7815
|
}
|
|
7916
7816
|
async down(queryRunner) {
|
|
7917
|
-
await queryRunner.query(`
|
|
7817
|
+
await queryRunner.query(`ALTER TABLE "PresentationDefinitionItem" ALTER COLUMN "definition_payload" SET NOT NULL`);
|
|
7918
7818
|
}
|
|
7919
7819
|
};
|
|
7920
7820
|
|
|
7921
|
-
// src/migrations/
|
|
7922
|
-
var
|
|
7821
|
+
// src/migrations/sqlite/1756975340000-UpdatePresentationDefinitionItemNullable.ts
|
|
7822
|
+
var UpdatePresentationDefinitionItemNullableSqlite1756975340000 = class {
|
|
7923
7823
|
static {
|
|
7924
|
-
__name(this, "
|
|
7824
|
+
__name(this, "UpdatePresentationDefinitionItemNullableSqlite1756975340000");
|
|
7925
7825
|
}
|
|
7926
|
-
name = "
|
|
7826
|
+
name = "UpdatePresentationDefinitionItemNullable1756975340000";
|
|
7927
7827
|
async up(queryRunner) {
|
|
7928
|
-
await queryRunner.query(`
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
"originalCredential" TEXT,
|
|
7957
|
-
"sharePurpose" TEXT,
|
|
7958
|
-
"description" TEXT NOT NULL,
|
|
7959
|
-
"data" TEXT,
|
|
7960
|
-
"diagnosticData" TEXT,
|
|
7961
|
-
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
7962
|
-
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
7963
|
-
CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
|
|
7828
|
+
await queryRunner.query(`
|
|
7829
|
+
CREATE TABLE "temporary_PresentationDefinitionItem" (
|
|
7830
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
7831
|
+
"definition_id" varchar(255) NOT NULL,
|
|
7832
|
+
"version" varchar(255) NOT NULL,
|
|
7833
|
+
"tenant_id" varchar(255),
|
|
7834
|
+
"purpose" varchar(255),
|
|
7835
|
+
"name" varchar(255),
|
|
7836
|
+
"definition_payload" text,
|
|
7837
|
+
"dcql_payload" text,
|
|
7838
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7839
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7840
|
+
CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
|
|
7841
|
+
)
|
|
7842
|
+
`);
|
|
7843
|
+
await queryRunner.query(`
|
|
7844
|
+
INSERT INTO "temporary_PresentationDefinitionItem"(
|
|
7845
|
+
"id", "definition_id", "version", "tenant_id", "purpose", "name",
|
|
7846
|
+
"definition_payload", "dcql_payload", "created_at", "last_updated_at"
|
|
7847
|
+
)
|
|
7848
|
+
SELECT
|
|
7849
|
+
"id", "definition_id", "version", "tenant_id", "purpose", "name",
|
|
7850
|
+
"definition_payload", "dcql_payload", "created_at", "last_updated_at"
|
|
7851
|
+
FROM "PresentationDefinitionItem"
|
|
7852
|
+
`);
|
|
7853
|
+
await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
|
|
7854
|
+
await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
|
|
7855
|
+
await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
|
|
7964
7856
|
}
|
|
7965
7857
|
async down(queryRunner) {
|
|
7966
|
-
await queryRunner.query(`
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7858
|
+
await queryRunner.query(`
|
|
7859
|
+
CREATE TABLE "temporary_PresentationDefinitionItem" (
|
|
7860
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
7861
|
+
"definition_id" varchar(255) NOT NULL,
|
|
7862
|
+
"version" varchar(255) NOT NULL,
|
|
7863
|
+
"tenant_id" varchar(255),
|
|
7864
|
+
"purpose" varchar(255),
|
|
7865
|
+
"name" varchar(255),
|
|
7866
|
+
"definition_payload" text NOT NULL,
|
|
7867
|
+
"dcql_payload" text,
|
|
7868
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7869
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
7870
|
+
CONSTRAINT "UQ_PresentationDefinitionItem_definition_id_version" UNIQUE ("definition_id", "version")
|
|
7871
|
+
)
|
|
7872
|
+
`);
|
|
7873
|
+
await queryRunner.query(`
|
|
7874
|
+
INSERT INTO "temporary_PresentationDefinitionItem"(
|
|
7875
|
+
"id", "definition_id", "version", "tenant_id", "purpose", "name",
|
|
7876
|
+
"definition_payload", "dcql_payload", "created_at", "last_updated_at"
|
|
7877
|
+
)
|
|
7878
|
+
SELECT
|
|
7879
|
+
"id", "definition_id", "version", "tenant_id", "purpose", "name",
|
|
7880
|
+
"definition_payload", "dcql_payload", "created_at", "last_updated_at"
|
|
7881
|
+
FROM "PresentationDefinitionItem"
|
|
7882
|
+
`);
|
|
7883
|
+
await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`);
|
|
7884
|
+
await queryRunner.query(`ALTER TABLE "temporary_PresentationDefinitionItem" RENAME TO "PresentationDefinitionItem"`);
|
|
7885
|
+
await queryRunner.query(`CREATE INDEX "IDX_PresentationDefinitionItem_version" ON "PresentationDefinitionItem" ("version")`);
|
|
7974
7886
|
}
|
|
7975
7887
|
};
|
|
7976
7888
|
|
|
7977
|
-
// src/migrations/generic/
|
|
7889
|
+
// src/migrations/generic/13-UpdatePresentationDefinitionItemNullable.ts
|
|
7978
7890
|
var debug12 = Debug12("sphereon:ssi-sdk:migrations");
|
|
7979
|
-
var
|
|
7891
|
+
var UpdatePresentationDefinitionItemNullable1741895824000 = class {
|
|
7980
7892
|
static {
|
|
7981
|
-
__name(this, "
|
|
7893
|
+
__name(this, "UpdatePresentationDefinitionItemNullable1741895824000");
|
|
7982
7894
|
}
|
|
7983
|
-
name = "
|
|
7895
|
+
name = "UpdatePresentationDefinitionItemNullable1741895824000";
|
|
7984
7896
|
async up(queryRunner) {
|
|
7985
|
-
debug12("migration:
|
|
7897
|
+
debug12("migration: updating presentation definition item nullable fields");
|
|
7986
7898
|
const dbType = queryRunner.connection.driver.options.type;
|
|
7987
7899
|
switch (dbType) {
|
|
7988
7900
|
case "postgres": {
|
|
7989
7901
|
debug12("using postgres migration file");
|
|
7990
|
-
const mig = new
|
|
7902
|
+
const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
|
|
7991
7903
|
await mig.up(queryRunner);
|
|
7992
7904
|
debug12("Migration statements executed");
|
|
7993
7905
|
return;
|
|
@@ -7996,7 +7908,7 @@ var CreateAuditEvents1701635835330 = class {
|
|
|
7996
7908
|
case "expo":
|
|
7997
7909
|
case "react-native": {
|
|
7998
7910
|
debug12("using sqlite/react-native migration file");
|
|
7999
|
-
const mig = new
|
|
7911
|
+
const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
|
|
8000
7912
|
await mig.up(queryRunner);
|
|
8001
7913
|
debug12("Migration statements executed");
|
|
8002
7914
|
return;
|
|
@@ -8006,12 +7918,12 @@ var CreateAuditEvents1701635835330 = class {
|
|
|
8006
7918
|
}
|
|
8007
7919
|
}
|
|
8008
7920
|
async down(queryRunner) {
|
|
8009
|
-
debug12("migration: reverting
|
|
7921
|
+
debug12("migration: reverting presentation definition item nullable fields");
|
|
8010
7922
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8011
7923
|
switch (dbType) {
|
|
8012
7924
|
case "postgres": {
|
|
8013
7925
|
debug12("using postgres migration file");
|
|
8014
|
-
const mig = new
|
|
7926
|
+
const mig = new UpdatePresentationDefinitionItemNullablePG1741895824000();
|
|
8015
7927
|
await mig.down(queryRunner);
|
|
8016
7928
|
debug12("Migration statements executed");
|
|
8017
7929
|
return;
|
|
@@ -8020,258 +7932,310 @@ var CreateAuditEvents1701635835330 = class {
|
|
|
8020
7932
|
case "expo":
|
|
8021
7933
|
case "react-native": {
|
|
8022
7934
|
debug12("using sqlite/react-native migration file");
|
|
8023
|
-
const mig = new
|
|
7935
|
+
const mig = new UpdatePresentationDefinitionItemNullableSqlite1756975340000();
|
|
8024
7936
|
await mig.down(queryRunner);
|
|
8025
7937
|
debug12("Migration statements executed");
|
|
8026
7938
|
return;
|
|
8027
7939
|
}
|
|
8028
|
-
default:
|
|
8029
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8030
|
-
}
|
|
8031
|
-
}
|
|
8032
|
-
};
|
|
8033
|
-
|
|
8034
|
-
// src/migrations/generic/6-CreateDigitalCredential.ts
|
|
8035
|
-
import Debug13 from "debug";
|
|
8036
|
-
|
|
8037
|
-
// src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
|
|
8038
|
-
var CreateDigitalCredential1708525189001 = class {
|
|
8039
|
-
static {
|
|
8040
|
-
__name(this, "CreateDigitalCredential1708525189001");
|
|
8041
|
-
}
|
|
8042
|
-
name = "CreateDigitalCredential1708525189001";
|
|
8043
|
-
async up(queryRunner) {
|
|
8044
|
-
await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
|
|
8045
|
-
await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
|
|
8046
|
-
await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
|
|
8047
|
-
await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
|
|
8048
|
-
await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
|
|
8049
|
-
await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
|
|
8050
|
-
await queryRunner.query(`
|
|
8051
|
-
CREATE TABLE "DigitalCredential" (
|
|
8052
|
-
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
8053
|
-
"parent_id" text,
|
|
8054
|
-
"document_type" "digital_document_type" NOT NULL,
|
|
8055
|
-
"regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
|
|
8056
|
-
"document_format" "digital_credential_document_format" NOT NULL,
|
|
8057
|
-
"credential_role" "digital_credential_credential_role" NOT NULL,
|
|
8058
|
-
"raw_document" text NOT NULL,
|
|
8059
|
-
"uniform_document" text NOT NULL,
|
|
8060
|
-
"credential_id" text,
|
|
8061
|
-
"hash" text NOT NULL,
|
|
8062
|
-
"kms_key_ref" text,
|
|
8063
|
-
"identifier_method" text,
|
|
8064
|
-
"issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
|
|
8065
|
-
"subject_correlation_type" "digital_credential_correlation_type",
|
|
8066
|
-
"issuer_correlation_id" text NOT NULL,
|
|
8067
|
-
"subject_correlation_id" text,
|
|
8068
|
-
"verified_state" "digital_credential_state_type",
|
|
8069
|
-
"issuer_signed" boolean,
|
|
8070
|
-
"rp_correlation_id" text,
|
|
8071
|
-
"rp_correlation_type" "digital_credential_correlation_type",
|
|
8072
|
-
"tenant_id" text,
|
|
8073
|
-
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8074
|
-
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8075
|
-
"presented_at" DATE,
|
|
8076
|
-
"valid_from" DATE,
|
|
8077
|
-
"valid_until" DATE,
|
|
8078
|
-
"verified_at" DATE,
|
|
8079
|
-
"revoked_at" DATE,
|
|
8080
|
-
PRIMARY KEY ("id"),
|
|
8081
|
-
UNIQUE ("hash", "credential_role")
|
|
8082
|
-
)
|
|
8083
|
-
`);
|
|
8084
|
-
}
|
|
8085
|
-
async down(queryRunner) {
|
|
8086
|
-
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
8087
|
-
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
8088
|
-
await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
|
|
8089
|
-
await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
|
|
8090
|
-
await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
|
|
8091
|
-
await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
|
|
8092
|
-
await queryRunner.query(`DROP TYPE "digital_document_type"`);
|
|
8093
|
-
}
|
|
8094
|
-
};
|
|
8095
|
-
|
|
8096
|
-
// src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
|
|
8097
|
-
var CreateDigitalCredential1708525189002 = class {
|
|
8098
|
-
static {
|
|
8099
|
-
__name(this, "CreateDigitalCredential1708525189002");
|
|
8100
|
-
}
|
|
8101
|
-
name = "CreateDigitalCredential1708525189002";
|
|
8102
|
-
async up(queryRunner) {
|
|
8103
|
-
await queryRunner.query(`
|
|
8104
|
-
CREATE TABLE "DigitalCredential" (
|
|
8105
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
8106
|
-
"parent_id" text,
|
|
8107
|
-
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
8108
|
-
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
8109
|
-
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
8110
|
-
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
8111
|
-
"raw_document" text NOT NULL,
|
|
8112
|
-
"uniform_document" text NOT NULL,
|
|
8113
|
-
"credential_id" text,
|
|
8114
|
-
"hash" text NOT NULL,
|
|
8115
|
-
"kms_key_ref" text,
|
|
8116
|
-
"identifier_method" text,
|
|
8117
|
-
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
8118
|
-
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
8119
|
-
"issuer_correlation_id" text NOT NULL,
|
|
8120
|
-
"subject_correlation_id" text,
|
|
8121
|
-
"issuer_signed" boolean,
|
|
8122
|
-
"rp_correlation_id" text,
|
|
8123
|
-
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
8124
|
-
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
|
|
8125
|
-
"tenant_id" text,
|
|
8126
|
-
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8127
|
-
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8128
|
-
"presented_at" datetime,
|
|
8129
|
-
"valid_from" datetime,
|
|
8130
|
-
"valid_until" datetime,
|
|
8131
|
-
"verified_at" datetime,
|
|
8132
|
-
"revoked_at" datetime,
|
|
8133
|
-
UNIQUE ("hash", "credential_role")
|
|
8134
|
-
)
|
|
8135
|
-
`);
|
|
8136
|
-
}
|
|
8137
|
-
async down(queryRunner) {
|
|
8138
|
-
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
7940
|
+
default:
|
|
7941
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
7942
|
+
}
|
|
8139
7943
|
}
|
|
8140
7944
|
};
|
|
8141
7945
|
|
|
8142
|
-
// src/migrations/generic/
|
|
7946
|
+
// src/migrations/generic/2-CreateIssuanceBranding.ts
|
|
7947
|
+
import Debug13 from "debug";
|
|
8143
7948
|
var debug13 = Debug13("sphereon:ssi-sdk:migrations");
|
|
8144
|
-
var
|
|
7949
|
+
var CreateIssuanceBranding1659463079429 = class {
|
|
8145
7950
|
static {
|
|
8146
|
-
__name(this, "
|
|
7951
|
+
__name(this, "CreateIssuanceBranding1659463079429");
|
|
8147
7952
|
}
|
|
8148
|
-
name = "
|
|
7953
|
+
name = "CreateIssuanceBranding1659463079429";
|
|
8149
7954
|
async up(queryRunner) {
|
|
8150
|
-
debug13("migration: creating
|
|
7955
|
+
debug13("migration: creating issuance branding tables");
|
|
8151
7956
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8152
7957
|
switch (dbType) {
|
|
8153
7958
|
case "postgres": {
|
|
8154
|
-
debug13("using postgres migration file
|
|
8155
|
-
const mig = new
|
|
7959
|
+
debug13("using postgres migration file");
|
|
7960
|
+
const mig = new CreateIssuanceBranding1685628974232();
|
|
8156
7961
|
await mig.up(queryRunner);
|
|
8157
|
-
debug13("
|
|
7962
|
+
debug13("Migration statements executed");
|
|
8158
7963
|
return;
|
|
8159
7964
|
}
|
|
8160
7965
|
case "sqlite":
|
|
8161
7966
|
case "expo":
|
|
8162
7967
|
case "react-native": {
|
|
8163
|
-
debug13("using sqlite/react-native migration file
|
|
8164
|
-
const mig = new
|
|
7968
|
+
debug13("using sqlite/react-native migration file");
|
|
7969
|
+
const mig = new CreateIssuanceBranding1685628973231();
|
|
8165
7970
|
await mig.up(queryRunner);
|
|
8166
|
-
debug13("
|
|
7971
|
+
debug13("Migration statements executed");
|
|
8167
7972
|
return;
|
|
8168
7973
|
}
|
|
8169
7974
|
default:
|
|
8170
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo
|
|
7975
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8171
7976
|
}
|
|
8172
7977
|
}
|
|
8173
7978
|
async down(queryRunner) {
|
|
8174
|
-
debug13("migration: reverting
|
|
7979
|
+
debug13("migration: reverting issuance branding tables");
|
|
8175
7980
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8176
7981
|
switch (dbType) {
|
|
8177
7982
|
case "postgres": {
|
|
8178
|
-
debug13("using postgres migration file
|
|
8179
|
-
const mig = new
|
|
7983
|
+
debug13("using postgres migration file");
|
|
7984
|
+
const mig = new CreateIssuanceBranding1685628974232();
|
|
8180
7985
|
await mig.down(queryRunner);
|
|
8181
|
-
debug13("
|
|
7986
|
+
debug13("Migration statements executed");
|
|
8182
7987
|
return;
|
|
8183
7988
|
}
|
|
8184
7989
|
case "sqlite":
|
|
8185
7990
|
case "expo":
|
|
8186
7991
|
case "react-native": {
|
|
8187
|
-
debug13("using sqlite/react-native migration file
|
|
8188
|
-
const mig = new
|
|
7992
|
+
debug13("using sqlite/react-native migration file");
|
|
7993
|
+
const mig = new CreateIssuanceBranding1685628973231();
|
|
8189
7994
|
await mig.down(queryRunner);
|
|
8190
|
-
debug13("
|
|
7995
|
+
debug13("Migration statements executed");
|
|
8191
7996
|
return;
|
|
8192
7997
|
}
|
|
8193
7998
|
default:
|
|
8194
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo
|
|
7999
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8195
8000
|
}
|
|
8196
8001
|
}
|
|
8197
8002
|
};
|
|
8198
8003
|
|
|
8199
|
-
// src/migrations/generic/
|
|
8004
|
+
// src/migrations/generic/3-CreateContacts.ts
|
|
8200
8005
|
import Debug14 from "debug";
|
|
8201
8006
|
|
|
8202
|
-
// src/migrations/
|
|
8203
|
-
var
|
|
8007
|
+
// src/migrations/sqlite/1690925872693-CreateContacts.ts
|
|
8008
|
+
var CreateContacts1690925872693 = class {
|
|
8204
8009
|
static {
|
|
8205
|
-
__name(this, "
|
|
8010
|
+
__name(this, "CreateContacts1690925872693");
|
|
8206
8011
|
}
|
|
8207
|
-
name = "
|
|
8012
|
+
name = "CreateContacts1690925872693";
|
|
8208
8013
|
async up(queryRunner) {
|
|
8209
|
-
await queryRunner.query(`
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8014
|
+
await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
|
|
8015
|
+
await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
|
|
8016
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
8017
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
8018
|
+
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
|
|
8019
|
+
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
|
|
8020
|
+
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
8021
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
8022
|
+
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`);
|
|
8023
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`);
|
|
8024
|
+
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
8025
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
8026
|
+
await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"))`);
|
|
8027
|
+
await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`);
|
|
8028
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
8029
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
8030
|
+
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"))`);
|
|
8031
|
+
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`);
|
|
8032
|
+
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
8033
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
8034
|
+
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identity_id"))`);
|
|
8035
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`);
|
|
8036
|
+
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
8037
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
8038
|
+
await queryRunner.query(`CREATE TABLE "PartyType" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('naturalPerson','organization') ) NOT NULL, "origin" varchar CHECK( "origin" IN ('INTERNAL', 'EXTERNAL') ) NOT NULL, "name" varchar(255) NOT NULL, "description" varchar(255), "tenant_id" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"))`);
|
|
8039
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
|
|
8040
|
+
await queryRunner.query(`CREATE TABLE "BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"))`);
|
|
8041
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
8042
|
+
await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
8043
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
8044
|
+
await queryRunner.query(`CREATE TABLE "Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL)`);
|
|
8045
|
+
await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"))`);
|
|
8046
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
8047
|
+
await queryRunner.query(`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identity_id" varchar, CONSTRAINT "REL_CorrelationIdentifier_identity_id" UNIQUE ("identity_id"), CONSTRAINT "UQ_CorrelationIdentifier_correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8048
|
+
await queryRunner.query(`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`);
|
|
8049
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
8050
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`);
|
|
8051
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
8052
|
+
await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8053
|
+
await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
|
|
8054
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
8055
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
|
|
8056
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
8057
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
8058
|
+
await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8059
|
+
await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
|
|
8060
|
+
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
8061
|
+
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
|
|
8062
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
8063
|
+
await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8064
|
+
await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "street_name" varchar(255) NOT NULL, "street_number" varchar(255) NOT NULL, "postal_code" varchar(255) NOT NULL, "city_name" varchar(255) NOT NULL, "province_name" varchar(255) NOT NULL, "country_code" varchar(2) NOT NULL, "building_name" varchar(255), "partyId" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8065
|
+
await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
|
8066
|
+
await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
|
|
8067
|
+
await queryRunner.query(`DROP TABLE "Party"`);
|
|
8068
|
+
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
|
|
8069
|
+
await queryRunner.query(`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"), CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8070
|
+
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "partyId" FROM "Identity"`);
|
|
8071
|
+
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
8072
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
8073
|
+
await queryRunner.query(`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identity_id" varchar, CONSTRAINT "REL_Connection_identity_id" UNIQUE ("identity_id"), CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8074
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`);
|
|
8075
|
+
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
8076
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`);
|
|
8077
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
8078
|
+
await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8079
|
+
await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
8080
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
8081
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
|
|
8082
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
8083
|
+
await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
|
|
8084
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
|
|
8085
|
+
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
|
|
8086
|
+
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', datetime('now'), datetime('now'))`);
|
|
8087
|
+
await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
|
|
8088
|
+
await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
|
|
8089
|
+
await queryRunner.query(`DROP TABLE "Contact"`);
|
|
8226
8090
|
}
|
|
8227
8091
|
async down(queryRunner) {
|
|
8228
|
-
await queryRunner.query(`
|
|
8092
|
+
await queryRunner.query(`CREATE TABLE "Contact" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "name" varchar(255), "alias" varchar(255))`);
|
|
8093
|
+
await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
|
|
8094
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
8095
|
+
await queryRunner.query(`DROP TABLE "Party"`);
|
|
8096
|
+
await queryRunner.query(`CREATE TABLE "BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connectionId" varchar)`);
|
|
8097
|
+
await queryRunner.query(`INSERT INTO "BaseConfigEntity"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
8098
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
8099
|
+
await queryRunner.query(`CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
|
8100
|
+
await queryRunner.query(`INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`);
|
|
8101
|
+
await queryRunner.query(`DROP TABLE "Party"`);
|
|
8102
|
+
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`);
|
|
8103
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
8104
|
+
await queryRunner.query(`CREATE TABLE "temporary_PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8105
|
+
await queryRunner.query(`INSERT INTO "temporary_PartyRelationship"("id", "left_id", "right_id", "created_at", "last_updated_at") SELECT "id", "left_id", "right_id", "created_at", "last_updated_at" FROM "PartyRelationship"`);
|
|
8106
|
+
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
8107
|
+
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`);
|
|
8108
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
8109
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
8110
|
+
await queryRunner.query(`CREATE TABLE "temporary_BaseContact" ("id" varchar PRIMARY KEY NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "legal_name" varchar(255), "display_name" varchar(255), "first_name" varchar(255), "middle_name" varchar(255), "last_name" varchar(255), "type" varchar NOT NULL, "party_id" varchar, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8111
|
+
await queryRunner.query(`INSERT INTO "temporary_BaseContact"("id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id") SELECT "id", "created_at", "last_updated_at", "legal_name", "display_name", "first_name", "middle_name", "last_name", "type", "party_id" FROM "BaseContact"`);
|
|
8112
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
8113
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`);
|
|
8114
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
8115
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
8116
|
+
await queryRunner.query(`CREATE TABLE "temporary_BaseConfig" ("id" varchar PRIMARY KEY NOT NULL, "identifier" varchar(255), "redirect_url" varchar(255), "session_id" varchar(255), "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" varchar NOT NULL, "connection_id" varchar, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
|
|
8117
|
+
await queryRunner.query(`INSERT INTO "temporary_BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfig"`);
|
|
8118
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
8119
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`);
|
|
8120
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
8121
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
|
|
8122
|
+
await queryRunner.query(`DROP TABLE "PartyType"`);
|
|
8123
|
+
await queryRunner.query(`DROP TABLE "Connection"`);
|
|
8124
|
+
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
8125
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`);
|
|
8126
|
+
await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
|
|
8127
|
+
await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
|
|
8229
8128
|
}
|
|
8230
8129
|
};
|
|
8231
8130
|
|
|
8232
|
-
// src/migrations/
|
|
8233
|
-
|
|
8131
|
+
// src/migrations/postgres/1690925872592-CreateContacts.ts
|
|
8132
|
+
import { enablePostgresUuidExtension as enablePostgresUuidExtension3 } from "@sphereon/ssi-sdk.core";
|
|
8133
|
+
var CreateContacts1690925872592 = class {
|
|
8234
8134
|
static {
|
|
8235
|
-
__name(this, "
|
|
8135
|
+
__name(this, "CreateContacts1690925872592");
|
|
8236
8136
|
}
|
|
8237
|
-
name = "
|
|
8137
|
+
name = "CreateContacts1690925872592";
|
|
8238
8138
|
async up(queryRunner) {
|
|
8239
|
-
await queryRunner
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8139
|
+
await enablePostgresUuidExtension3(queryRunner);
|
|
8140
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`);
|
|
8141
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
|
|
8142
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`);
|
|
8143
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`);
|
|
8144
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identityId" TO "identity_id"`);
|
|
8145
|
+
await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identityId" TO "identity_id"`);
|
|
8146
|
+
await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`);
|
|
8147
|
+
await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
|
|
8148
|
+
await queryRunner.query(`CREATE TABLE "PartyType" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."PartyType_type_enum" NOT NULL, "origin" "public"."PartyOrigin_type_enum" NOT NULL, "name" character varying(255) NOT NULL, "description" character varying(255), "tenant_id" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_PartyType_name" UNIQUE ("name"), CONSTRAINT "PK_PartyType_id" PRIMARY KEY ("id"))`);
|
|
8149
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`);
|
|
8150
|
+
await queryRunner.query(`CREATE TABLE "BaseContact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "legal_name" character varying(255), "display_name" character varying(255), "first_name" character varying(255), "middle_name" character varying(255), "last_name" character varying(255), "type" character varying NOT NULL, "party_id" uuid, CONSTRAINT "UQ_BaseContact_legal_name" UNIQUE ("legal_name"), CONSTRAINT "REL_BaseContact_party_id" UNIQUE ("party_id"), CONSTRAINT "PK_BaseContact_id" PRIMARY KEY ("id"))`);
|
|
8151
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`);
|
|
8152
|
+
await queryRunner.query(`CREATE TABLE "PartyRelationship" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "left_id" uuid NOT NULL, "right_id" uuid NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PartyRelationship_id" PRIMARY KEY ("id"))`);
|
|
8153
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`);
|
|
8154
|
+
await queryRunner.query(`CREATE TABLE "ElectronicAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "electronic_address" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "partyId" uuid, CONSTRAINT "PK_ElectronicAddress_id" PRIMARY KEY ("id"))`);
|
|
8155
|
+
await queryRunner.query(`CREATE TABLE "PhysicalAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "street_name" character varying(255) NOT NULL, "street_number" character varying(255) NOT NULL, "postal_code" character varying(255) NOT NULL, "city_name" character varying(255) NOT NULL, "province_name" character varying(255) NOT NULL, "country_code" character varying(2) NOT NULL, "building_name" character varying(255), "partyId" uuid, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_PhysicalAddress_id" PRIMARY KEY ("id"))`);
|
|
8156
|
+
await queryRunner.query(`CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`);
|
|
8157
|
+
await queryRunner.query(`CREATE TABLE "BaseConfig" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "identifier" character varying(255), "redirect_url" character varying(255), "session_id" character varying(255), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" character varying NOT NULL, "connection_id" uuid, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "PK_BaseConfig_id" PRIMARY KEY ("id"))`);
|
|
8158
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`);
|
|
8159
|
+
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`);
|
|
8160
|
+
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`);
|
|
8161
|
+
await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`);
|
|
8162
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`);
|
|
8163
|
+
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`);
|
|
8164
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8165
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8166
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD CONSTRAINT "FK_BaseContact_party_id" FOREIGN KEY ("party_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8167
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_left_id" FOREIGN KEY ("left_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8168
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD CONSTRAINT "FK_PartyRelationship_right_id" FOREIGN KEY ("right_id") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8169
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8170
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8171
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
8172
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8173
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8174
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD CONSTRAINT "FK_BaseConfig_connection_id" FOREIGN KEY ("connection_id") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8175
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME CONSTRAINT "UQ_Correlation_id" TO "UQ_CorrelationIdentifier_correlation_id"`);
|
|
8176
|
+
await queryRunner.query(`ALTER TABLE "Identity" RENAME CONSTRAINT "UQ_Identity_Alias" TO "UQ_Identity_alias"`);
|
|
8177
|
+
await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connectionId" FROM "BaseConfigEntity"`);
|
|
8178
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`);
|
|
8179
|
+
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'INTERNAL', 'Sphereon_default_organization_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
|
|
8180
|
+
await queryRunner.query(`INSERT INTO "PartyType"(id, type, origin, name, description, tenant_id, created_at, last_updated_at) VALUES ('7d248798-41ca-4fc1-a130-9934b43d532e', 'naturalPerson', 'INTERNAL', 'Sphereon_default_natural_person_type', 'sphereon_default_natural_person', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`);
|
|
8181
|
+
await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM "Contact"`);
|
|
8182
|
+
await queryRunner.query(`INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`);
|
|
8183
|
+
await queryRunner.query(`DROP TABLE "Contact"`);
|
|
8255
8184
|
}
|
|
8256
8185
|
async down(queryRunner) {
|
|
8257
|
-
await queryRunner.query(`
|
|
8186
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`);
|
|
8187
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`);
|
|
8188
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`);
|
|
8189
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`);
|
|
8190
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`);
|
|
8191
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`);
|
|
8192
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`);
|
|
8193
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`);
|
|
8194
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`);
|
|
8195
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`);
|
|
8196
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`);
|
|
8197
|
+
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`);
|
|
8198
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`);
|
|
8199
|
+
await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`);
|
|
8200
|
+
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`);
|
|
8201
|
+
await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`);
|
|
8202
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`);
|
|
8203
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`);
|
|
8204
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`);
|
|
8205
|
+
await queryRunner.query(`DROP TABLE "Party"`);
|
|
8206
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`);
|
|
8207
|
+
await queryRunner.query(`DROP TABLE "PartyRelationship"`);
|
|
8208
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`);
|
|
8209
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`);
|
|
8210
|
+
await queryRunner.query(`DROP TABLE "ElectronicAddress"`);
|
|
8211
|
+
await queryRunner.query(`DROP TABLE "PhysicalAddress"`);
|
|
8212
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`);
|
|
8213
|
+
await queryRunner.query(`DROP TABLE "PartyType"`);
|
|
8214
|
+
await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`);
|
|
8215
|
+
await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`);
|
|
8216
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8217
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8218
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8219
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
|
8220
|
+
await queryRunner.query(`CREATE TABLE "Contact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "name" character varying(255), "alias" character varying(255), CONSTRAINT "PK_Contact_id" PRIMARY KEY ("id"))`);
|
|
8221
|
+
await queryRunner.query(`INSERT INTO "Contact"(id, uri, created_at, last_updated_at, name, alias) SELECT id, uri, created_at, last_updated_at, (SELECT legal_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id"), (SELECT display_name FROM "BaseContact" WHERE "BaseContact"."party_id" = "Party"."id") FROM "Party" WHERE party_type_id = '3875c12e-fdaa-4ef6-a340-c936e054b627'`);
|
|
8258
8222
|
}
|
|
8259
8223
|
};
|
|
8260
8224
|
|
|
8261
|
-
// src/migrations/generic/
|
|
8225
|
+
// src/migrations/generic/3-CreateContacts.ts
|
|
8262
8226
|
var debug14 = Debug14("sphereon:ssi-sdk:migrations");
|
|
8263
|
-
var
|
|
8227
|
+
var CreateContacts1690925872318 = class {
|
|
8264
8228
|
static {
|
|
8265
|
-
__name(this, "
|
|
8229
|
+
__name(this, "CreateContacts1690925872318");
|
|
8266
8230
|
}
|
|
8267
|
-
name = "
|
|
8231
|
+
name = "CreateContacts1690925872318";
|
|
8268
8232
|
async up(queryRunner) {
|
|
8269
|
-
debug14("migration: creating
|
|
8233
|
+
debug14("migration: creating contacts tables");
|
|
8270
8234
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8271
8235
|
switch (dbType) {
|
|
8272
8236
|
case "postgres": {
|
|
8273
8237
|
debug14("using postgres migration file");
|
|
8274
|
-
const mig = new
|
|
8238
|
+
const mig = new CreateContacts1690925872592();
|
|
8275
8239
|
await mig.up(queryRunner);
|
|
8276
8240
|
debug14("Migration statements executed");
|
|
8277
8241
|
return;
|
|
@@ -8280,7 +8244,7 @@ var CreateMachineStateStore1708098041262 = class {
|
|
|
8280
8244
|
case "expo":
|
|
8281
8245
|
case "react-native": {
|
|
8282
8246
|
debug14("using sqlite/react-native migration file");
|
|
8283
|
-
const mig = new
|
|
8247
|
+
const mig = new CreateContacts1690925872693();
|
|
8284
8248
|
await mig.up(queryRunner);
|
|
8285
8249
|
debug14("Migration statements executed");
|
|
8286
8250
|
return;
|
|
@@ -8290,12 +8254,12 @@ var CreateMachineStateStore1708098041262 = class {
|
|
|
8290
8254
|
}
|
|
8291
8255
|
}
|
|
8292
8256
|
async down(queryRunner) {
|
|
8293
|
-
debug14("migration: reverting
|
|
8257
|
+
debug14("migration: reverting contacts tables");
|
|
8294
8258
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8295
8259
|
switch (dbType) {
|
|
8296
8260
|
case "postgres": {
|
|
8297
8261
|
debug14("using postgres migration file");
|
|
8298
|
-
const mig = new
|
|
8262
|
+
const mig = new CreateContacts1690925872592();
|
|
8299
8263
|
await mig.down(queryRunner);
|
|
8300
8264
|
debug14("Migration statements executed");
|
|
8301
8265
|
return;
|
|
@@ -8304,7 +8268,7 @@ var CreateMachineStateStore1708098041262 = class {
|
|
|
8304
8268
|
case "expo":
|
|
8305
8269
|
case "react-native": {
|
|
8306
8270
|
debug14("using sqlite/react-native migration file");
|
|
8307
|
-
const mig = new
|
|
8271
|
+
const mig = new CreateContacts1690925872693();
|
|
8308
8272
|
await mig.down(queryRunner);
|
|
8309
8273
|
debug14("Migration statements executed");
|
|
8310
8274
|
return;
|
|
@@ -8315,303 +8279,380 @@ var CreateMachineStateStore1708098041262 = class {
|
|
|
8315
8279
|
}
|
|
8316
8280
|
};
|
|
8317
8281
|
|
|
8318
|
-
// src/migrations/generic/
|
|
8282
|
+
// src/migrations/generic/4-CreateStatusList.ts
|
|
8319
8283
|
import Debug15 from "debug";
|
|
8320
8284
|
|
|
8321
|
-
// src/migrations/postgres/
|
|
8322
|
-
var
|
|
8285
|
+
// src/migrations/postgres/1693866470001-CreateStatusList.ts
|
|
8286
|
+
var CreateStatusList1693866470001 = class {
|
|
8323
8287
|
static {
|
|
8324
|
-
__name(this, "
|
|
8288
|
+
__name(this, "CreateStatusList1693866470001");
|
|
8325
8289
|
}
|
|
8326
|
-
name = "
|
|
8290
|
+
name = "CreateStatusList1693866470001";
|
|
8327
8291
|
async up(queryRunner) {
|
|
8328
|
-
await queryRunner.query(`
|
|
8329
|
-
await queryRunner.query(`
|
|
8330
|
-
await queryRunner.query(`
|
|
8331
|
-
await queryRunner.query(`
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
await queryRunner.query(`
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8292
|
+
await queryRunner.query(`CREATE TYPE "StatusList_type_enum" AS ENUM('StatusList2021')`);
|
|
8293
|
+
await queryRunner.query(`CREATE TYPE "StatusList_drivertype_enum" AS ENUM('agent_typeorm', 'agent_kv_store', 'github', 'agent_filesystem')`);
|
|
8294
|
+
await queryRunner.query(`CREATE TYPE "StatusList_credentialidmode_enum" AS ENUM('ISSUANCE', 'PERSISTENCE', 'NEVER')`);
|
|
8295
|
+
await queryRunner.query(`CREATE TABLE "StatusListEntry"
|
|
8296
|
+
(
|
|
8297
|
+
"statusListId" character varying NOT NULL,
|
|
8298
|
+
"statusListIndex" integer NOT NULL,
|
|
8299
|
+
"credentialId" character varying,
|
|
8300
|
+
"credentialHash" character varying(128),
|
|
8301
|
+
"correlationId" character varying(255),
|
|
8302
|
+
"value" character varying(50),
|
|
8303
|
+
CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex")
|
|
8304
|
+
)`);
|
|
8305
|
+
await queryRunner.query(`CREATE TABLE "StatusList"
|
|
8306
|
+
(
|
|
8307
|
+
"id" character varying NOT NULL,
|
|
8308
|
+
"correlationId" character varying NOT NULL,
|
|
8309
|
+
"length" integer NOT NULL,
|
|
8310
|
+
"issuer" text NOT NULL,
|
|
8311
|
+
"type" "StatusList_type_enum" NOT NULL DEFAULT 'StatusList2021',
|
|
8312
|
+
"driverType" "StatusList_drivertype_enum" NOT NULL DEFAULT 'agent_typeorm',
|
|
8313
|
+
"credentialIdMode" "StatusList_credentialidmode_enum" NOT NULL DEFAULT 'ISSUANCE',
|
|
8314
|
+
"proofFormat" character varying NOT NULL DEFAULT 'lds',
|
|
8315
|
+
"indexingDirection" character varying NOT NULL DEFAULT 'rightToLeft',
|
|
8316
|
+
"statusPurpose" character varying NOT NULL DEFAULT 'revocation',
|
|
8317
|
+
"statusListCredential" text,
|
|
8318
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"),
|
|
8319
|
+
CONSTRAINT "PK_StatusList_Id" PRIMARY KEY ("id")
|
|
8320
|
+
)`);
|
|
8321
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry"
|
|
8322
|
+
ADD CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
8346
8323
|
}
|
|
8347
8324
|
async down(queryRunner) {
|
|
8348
|
-
await queryRunner.query(`ALTER TABLE "
|
|
8349
|
-
|
|
8350
|
-
await queryRunner.query(`
|
|
8351
|
-
await queryRunner.query(`
|
|
8352
|
-
await queryRunner.query(`
|
|
8353
|
-
await queryRunner.query(`
|
|
8354
|
-
await queryRunner.query(`
|
|
8355
|
-
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
|
|
8356
|
-
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
|
|
8357
|
-
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
|
|
8358
|
-
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
|
|
8359
|
-
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
|
|
8360
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
|
|
8361
|
-
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
|
|
8362
|
-
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
|
|
8363
|
-
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
|
|
8364
|
-
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
|
|
8365
|
-
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
|
|
8325
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry"
|
|
8326
|
+
DROP CONSTRAINT "FK_statusListEntry_statusListId"`);
|
|
8327
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
8328
|
+
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
8329
|
+
await queryRunner.query(`DROP TYPE "StatusList_credentialidmode_enum"`);
|
|
8330
|
+
await queryRunner.query(`DROP TYPE "StatusList_drivertype_enum"`);
|
|
8331
|
+
await queryRunner.query(`DROP TYPE "StatusList_type_enum"`);
|
|
8366
8332
|
}
|
|
8367
8333
|
};
|
|
8368
8334
|
|
|
8369
|
-
// src/migrations/sqlite/
|
|
8370
|
-
var
|
|
8335
|
+
// src/migrations/sqlite/1693866470000-CreateStatusList.ts
|
|
8336
|
+
var CreateStatusList1693866470002 = class {
|
|
8371
8337
|
static {
|
|
8372
|
-
__name(this, "
|
|
8338
|
+
__name(this, "CreateStatusList1693866470002");
|
|
8373
8339
|
}
|
|
8374
|
-
name = "
|
|
8340
|
+
name = "CreateStatusList1693866470002";
|
|
8375
8341
|
async up(queryRunner) {
|
|
8376
|
-
await queryRunner.query(`
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
await queryRunner.query(`
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8342
|
+
await queryRunner.query(`CREATE TABLE "StatusListEntry"
|
|
8343
|
+
(
|
|
8344
|
+
"statusListId" varchar NOT NULL,
|
|
8345
|
+
"statusListIndex" integer NOT NULL,
|
|
8346
|
+
"credentialId" varchar,
|
|
8347
|
+
"credentialHash" varchar(128),
|
|
8348
|
+
"correlationId" varchar(255),
|
|
8349
|
+
"value" varchar(50),
|
|
8350
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
8351
|
+
)`);
|
|
8352
|
+
await queryRunner.query(`CREATE TABLE "StatusList"
|
|
8353
|
+
(
|
|
8354
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
8355
|
+
"correlationId" varchar NOT NULL,
|
|
8356
|
+
"length" integer NOT NULL,
|
|
8357
|
+
"issuer" text NOT NULL,
|
|
8358
|
+
"type" varchar CHECK ( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
8359
|
+
"driverType" varchar CHECK ( "driverType" IN ('agent_typeorm', 'agent_kv_store', 'github',
|
|
8360
|
+
'agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
8361
|
+
"credentialIdMode" varchar CHECK ( "credentialIdMode" IN ('ISSUANCE', 'PERSISTENCE', 'NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
8362
|
+
"proofFormat" varchar CHECK ( "proofFormat" IN ('lds', 'jwt') ) NOT NULL DEFAULT ('lds'),
|
|
8363
|
+
"indexingDirection" varchar CHECK ( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
|
|
8364
|
+
"statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
|
|
8365
|
+
"statusListCredential" text,
|
|
8366
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
8367
|
+
)`);
|
|
8368
|
+
await queryRunner.query(`CREATE TABLE "temporary_StatusListEntry"
|
|
8369
|
+
(
|
|
8370
|
+
"statusListId" varchar NOT NULL,
|
|
8371
|
+
"statusListIndex" integer NOT NULL,
|
|
8372
|
+
"credentialId" varchar,
|
|
8373
|
+
"credentialHash" varchar(128),
|
|
8374
|
+
"correlationId" varchar(255),
|
|
8375
|
+
"value" varchar(50),
|
|
8376
|
+
CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
|
8377
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
8378
|
+
)`);
|
|
8379
|
+
await queryRunner.query(`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId",
|
|
8380
|
+
"credentialHash", "correlationId", "value")
|
|
8381
|
+
SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value"
|
|
8382
|
+
FROM "StatusListEntry"`);
|
|
8383
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
8384
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
8385
|
+
}
|
|
8386
|
+
async down(queryRunner) {
|
|
8387
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
8388
|
+
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
8389
|
+
}
|
|
8390
|
+
};
|
|
8391
|
+
|
|
8392
|
+
// src/migrations/postgres/1737110469001-UpdateStatusList.ts
|
|
8393
|
+
var UpdateStatusList1737110469001 = class {
|
|
8394
|
+
static {
|
|
8395
|
+
__name(this, "UpdateStatusList1737110469001");
|
|
8396
|
+
}
|
|
8397
|
+
name = "UpdateStatusList1737110469001";
|
|
8398
|
+
async up(queryRunner) {
|
|
8399
|
+
await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'OAuthStatusList'`);
|
|
8400
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" DROP NOT NULL`);
|
|
8401
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" DROP NOT NULL`);
|
|
8402
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD "bitsPerStatus" integer DEFAULT 1`);
|
|
8403
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ADD "expiresAt" timestamp with time zone`);
|
|
8404
|
+
}
|
|
8405
|
+
async down(queryRunner) {
|
|
8406
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "expiresAt"`);
|
|
8407
|
+
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "bitsPerStatus"`);
|
|
8408
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "statusPurpose" SET NOT NULL`);
|
|
8409
|
+
await queryRunner.query(`ALTER TABLE "StatusList" ALTER COLUMN "indexingDirection" SET NOT NULL`);
|
|
8410
|
+
}
|
|
8411
|
+
};
|
|
8412
|
+
|
|
8413
|
+
// src/migrations/sqlite/1737110469000-UpdateStatusList.ts
|
|
8414
|
+
var UpdateStatusList1737110469000 = class {
|
|
8415
|
+
static {
|
|
8416
|
+
__name(this, "UpdateStatusList1737110469000");
|
|
8417
|
+
}
|
|
8418
|
+
name = "UpdateStatusList1737110469000";
|
|
8419
|
+
async up(queryRunner) {
|
|
8420
|
+
await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
|
|
8421
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
8422
|
+
"correlationId" varchar NOT NULL,
|
|
8423
|
+
"length" integer NOT NULL,
|
|
8424
|
+
"issuer" text NOT NULL,
|
|
8425
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
8426
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
8427
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
8428
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
8429
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
8430
|
+
"statusPurpose" varchar,
|
|
8431
|
+
"statusListCredential" text,
|
|
8432
|
+
"bitsPerStatus" integer,
|
|
8433
|
+
"expiresAt" datetime,
|
|
8434
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
8435
|
+
)`);
|
|
8436
|
+
await queryRunner.query(`INSERT INTO "temporary_StatusList"(
|
|
8437
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
8438
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
8439
|
+
"statusListCredential"
|
|
8440
|
+
)
|
|
8441
|
+
SELECT
|
|
8442
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
8443
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
8444
|
+
"statusListCredential"
|
|
8445
|
+
FROM "StatusList"`);
|
|
8446
|
+
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
8447
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
8409
8448
|
}
|
|
8410
8449
|
async down(queryRunner) {
|
|
8411
|
-
await queryRunner.query(`
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
await queryRunner.query(`
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
await queryRunner.query(`
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8450
|
+
await queryRunner.query(`
|
|
8451
|
+
ALTER TABLE "StatusListEntry"
|
|
8452
|
+
RENAME COLUMN "entryCorrelationId" TO "correlationId"
|
|
8453
|
+
`);
|
|
8454
|
+
await queryRunner.query(`
|
|
8455
|
+
ALTER TABLE "StatusListEntry"
|
|
8456
|
+
DROP COLUMN "statusListCorrelationId"
|
|
8457
|
+
`);
|
|
8458
|
+
await queryRunner.query(`CREATE TABLE "temporary_StatusList" (
|
|
8459
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
8460
|
+
"correlationId" varchar NOT NULL,
|
|
8461
|
+
"length" integer NOT NULL,
|
|
8462
|
+
"issuer" text NOT NULL,
|
|
8463
|
+
"type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
8464
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
8465
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
8466
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
8467
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'),
|
|
8468
|
+
"statusPurpose" varchar NOT NULL DEFAULT ('revocation'),
|
|
8469
|
+
"statusListCredential" text,
|
|
8470
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
8471
|
+
)`);
|
|
8472
|
+
await queryRunner.query(`INSERT INTO "temporary_StatusList"(
|
|
8473
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
8474
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
8475
|
+
"statusListCredential"
|
|
8476
|
+
)
|
|
8477
|
+
SELECT
|
|
8478
|
+
"id", "correlationId", "length", "issuer",
|
|
8479
|
+
CASE WHEN "type" = 'OAuthStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
8480
|
+
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
8481
|
+
COALESCE("statusPurpose", 'revocation'), "statusListCredential"
|
|
8482
|
+
FROM "StatusList"`);
|
|
8483
|
+
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
8484
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
8429
8485
|
}
|
|
8430
8486
|
};
|
|
8431
8487
|
|
|
8432
|
-
// src/migrations/generic/
|
|
8488
|
+
// src/migrations/generic/4-CreateStatusList.ts
|
|
8433
8489
|
var debug15 = Debug15("sphereon:ssi-sdk:migrations");
|
|
8434
|
-
var
|
|
8490
|
+
var CreateStatusList1693866470000 = class {
|
|
8435
8491
|
static {
|
|
8436
|
-
__name(this, "
|
|
8492
|
+
__name(this, "CreateStatusList1693866470000");
|
|
8437
8493
|
}
|
|
8438
|
-
name = "
|
|
8494
|
+
name = "CreateStatusList1693866470000";
|
|
8439
8495
|
async up(queryRunner) {
|
|
8440
|
-
debug15("migration:
|
|
8496
|
+
debug15("migration: creating issuance branding tables");
|
|
8441
8497
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8498
|
+
if (dbType === "postgres") {
|
|
8499
|
+
debug15("using postgres migration files");
|
|
8500
|
+
const createMig = new CreateStatusList1693866470001();
|
|
8501
|
+
await createMig.up(queryRunner);
|
|
8502
|
+
const updateMig = new UpdateStatusList1737110469001();
|
|
8503
|
+
const up = await updateMig.up(queryRunner);
|
|
8504
|
+
debug15("Migration statements executed");
|
|
8505
|
+
return up;
|
|
8506
|
+
} else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
|
|
8507
|
+
debug15("using sqlite/react-native migration files");
|
|
8508
|
+
const createMig = new CreateStatusList1693866470002();
|
|
8509
|
+
await createMig.up(queryRunner);
|
|
8510
|
+
const updateMig = new UpdateStatusList1737110469000();
|
|
8511
|
+
const up = await updateMig.up(queryRunner);
|
|
8512
|
+
debug15("Migration statements executed");
|
|
8513
|
+
return up;
|
|
8514
|
+
} else {
|
|
8515
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8461
8516
|
}
|
|
8462
8517
|
}
|
|
8463
8518
|
async down(queryRunner) {
|
|
8464
|
-
debug15("migration: reverting
|
|
8519
|
+
debug15("migration: reverting issuance branding tables");
|
|
8465
8520
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8521
|
+
if (dbType === "postgres") {
|
|
8522
|
+
debug15("using postgres migration files");
|
|
8523
|
+
const updateMig = new UpdateStatusList1737110469001();
|
|
8524
|
+
await updateMig.down(queryRunner);
|
|
8525
|
+
const createMig = new CreateStatusList1693866470001();
|
|
8526
|
+
const down = await createMig.down(queryRunner);
|
|
8527
|
+
debug15("Migration statements executed");
|
|
8528
|
+
return down;
|
|
8529
|
+
} else if (dbType === "sqlite" || dbType === "react-native" || dbType === "expo") {
|
|
8530
|
+
debug15("using sqlite/react-native migration files");
|
|
8531
|
+
const updateMig = new UpdateStatusList1737110469000();
|
|
8532
|
+
await updateMig.down(queryRunner);
|
|
8533
|
+
const createMig = new CreateStatusList1693866470002();
|
|
8534
|
+
const down = await createMig.down(queryRunner);
|
|
8535
|
+
debug15("Migration statements executed");
|
|
8536
|
+
return down;
|
|
8537
|
+
} else {
|
|
8538
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8485
8539
|
}
|
|
8486
8540
|
}
|
|
8487
8541
|
};
|
|
8488
8542
|
|
|
8489
|
-
// src/migrations/generic/
|
|
8543
|
+
// src/migrations/generic/5-CreateAuditEvents.ts
|
|
8490
8544
|
import Debug16 from "debug";
|
|
8491
8545
|
|
|
8492
|
-
// src/migrations/
|
|
8493
|
-
var
|
|
8546
|
+
// src/migrations/sqlite/1701634819487-CreateAuditEvents.ts
|
|
8547
|
+
var CreateAuditEvents1701634819487 = class {
|
|
8494
8548
|
static {
|
|
8495
|
-
__name(this, "
|
|
8549
|
+
__name(this, "CreateAuditEvents1701634819487");
|
|
8496
8550
|
}
|
|
8497
|
-
name = "
|
|
8551
|
+
name = "CreateAuditEvents1701634819487";
|
|
8498
8552
|
async up(queryRunner) {
|
|
8499
|
-
await queryRunner.query(`
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
|
|
8527
|
-
)`);
|
|
8553
|
+
await queryRunner.query(`CREATE TABLE "AuditEvents" (
|
|
8554
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
8555
|
+
"eventType" varchar CHECK( "eventType" IN ('audit','activity','general') ) NOT NULL,
|
|
8556
|
+
"timestamp" datetime NOT NULL,
|
|
8557
|
+
"level" varchar CHECK( "level" IN ('0','1','2','3','4') ) NOT NULL,
|
|
8558
|
+
"correlationId" varchar NOT NULL,
|
|
8559
|
+
"system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','oid4vp','siopv2','PE','credentials','web3','profile','contact') ) NOT NULL,
|
|
8560
|
+
"subSystemType" varchar CHECK( "subSystemType" IN ('key','did_provider','did_resolver','oid4vp_op','oid4vci_client','siopv2_op','contact_manager','vc_issuer','vc_verifier','vc_persistence','transport','profile','api') ) NOT NULL,
|
|
8561
|
+
"actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL,
|
|
8562
|
+
"actionSubType" varchar NOT NULL,
|
|
8563
|
+
"initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL,
|
|
8564
|
+
"systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','url','email','hostname','phone','user') ),
|
|
8565
|
+
"systemCorrelationId" varchar,
|
|
8566
|
+
"systemAlias" varchar,
|
|
8567
|
+
"partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','url','email','hostname','phone') ),
|
|
8568
|
+
"partyCorrelationId" varchar,
|
|
8569
|
+
"partyAlias" varchar,
|
|
8570
|
+
"credentialType" varchar CHECK( "credentialType" IN ('JSON_LD','JWT','SD_JWT','MSO_MDOC') ),
|
|
8571
|
+
"credentialHash" varchar,
|
|
8572
|
+
"parentCredentialHash" varchar,
|
|
8573
|
+
"originalCredential" varchar,
|
|
8574
|
+
"sharePurpose" varchar,
|
|
8575
|
+
"description" varchar NOT NULL,
|
|
8576
|
+
"data" varchar,
|
|
8577
|
+
"diagnosticData" varchar,
|
|
8578
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8579
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
|
8528
8580
|
}
|
|
8529
8581
|
async down(queryRunner) {
|
|
8530
|
-
await queryRunner.query(`DROP TABLE "
|
|
8531
|
-
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
|
|
8532
|
-
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
8533
|
-
(
|
|
8534
|
-
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
8535
|
-
"label" character varying(255) NOT NULL,
|
|
8536
|
-
"value" character varying(255) NOT NULL,
|
|
8537
|
-
"identityId" uuid,
|
|
8538
|
-
CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
8539
|
-
)`);
|
|
8540
|
-
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
|
|
8541
|
-
SELECT "id", "label", "stringValue", "identityId"
|
|
8542
|
-
FROM "temporary_IdentityMetadata"`);
|
|
8543
|
-
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
8582
|
+
await queryRunner.query(`DROP TABLE "AuditEvents"`);
|
|
8544
8583
|
}
|
|
8545
8584
|
};
|
|
8546
8585
|
|
|
8547
|
-
// src/migrations/
|
|
8548
|
-
var
|
|
8586
|
+
// src/migrations/postgres/1701634812183-CreateAuditEvents.ts
|
|
8587
|
+
var CreateAuditEvents1701634812183 = class {
|
|
8549
8588
|
static {
|
|
8550
|
-
__name(this, "
|
|
8589
|
+
__name(this, "CreateAuditEvents1701634812183");
|
|
8551
8590
|
}
|
|
8552
|
-
name = "
|
|
8591
|
+
name = "CreateAuditEvents1701634812183";
|
|
8553
8592
|
async up(queryRunner) {
|
|
8554
|
-
await queryRunner.query(`
|
|
8555
|
-
await queryRunner.query(`CREATE
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8593
|
+
await queryRunner.query(`CREATE TYPE "public"."Level_enum" AS ENUM('0', '1', '2', '3', '4')`);
|
|
8594
|
+
await queryRunner.query(`CREATE TYPE "public"."System_enum" AS ENUM('general', 'kms', 'identity', 'oid4vci', 'oid4vp', 'siopv2', 'PE', 'credentials', 'web3', 'profile', 'contact')`);
|
|
8595
|
+
await queryRunner.query(`CREATE TYPE "public"."Subsystem_type_enum" AS ENUM('key', 'did_provider', 'did_resolver', 'oid4vp_op', 'oid4vci_client', 'siopv2_op', 'contact_manager', 'vc_issuer', 'vc_verifier', 'vc_persistence', 'transport', 'profile', 'api')`);
|
|
8596
|
+
await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`);
|
|
8597
|
+
await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`);
|
|
8598
|
+
await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone', 'user')`);
|
|
8599
|
+
await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`);
|
|
8600
|
+
await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`);
|
|
8601
|
+
await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
|
|
8602
|
+
await queryRunner.query(`CREATE TABLE "AuditEvents" (
|
|
8603
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
8604
|
+
"eventType" "public"."Event_type_enum" NOT NULL,
|
|
8605
|
+
"timestamp" TIMESTAMP NOT NULL,
|
|
8606
|
+
"level" "public"."Level_enum" NOT NULL,
|
|
8607
|
+
"correlationId" TEXT NOT NULL,
|
|
8608
|
+
"system" "public"."System_enum" NOT NULL,
|
|
8609
|
+
"subSystemType" "public"."Subsystem_type_enum" NOT NULL,
|
|
8610
|
+
"actionType" "public"."Action_type_enum" NOT NULL,
|
|
8611
|
+
"actionSubType" TEXT NOT NULL,
|
|
8612
|
+
"initiatorType" "public"."Initiator_type_enum" NOT NULL,
|
|
8613
|
+
"systemCorrelationIdType" "public"."System_correlation_id_type_enum",
|
|
8614
|
+
"systemCorrelationId" TEXT,
|
|
8615
|
+
"systemAlias" TEXT,
|
|
8616
|
+
"partyCorrelationType" "public"."Party_correlation_type_enum",
|
|
8617
|
+
"partyCorrelationId" TEXT,
|
|
8618
|
+
"partyAlias" TEXT,
|
|
8619
|
+
"credentialType" "public"."Event_credential_type_enum",
|
|
8620
|
+
"credentialHash" TEXT,
|
|
8621
|
+
"originalCredential" TEXT,
|
|
8622
|
+
"sharePurpose" TEXT,
|
|
8623
|
+
"description" TEXT NOT NULL,
|
|
8624
|
+
"data" TEXT,
|
|
8625
|
+
"diagnosticData" TEXT,
|
|
8626
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8627
|
+
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8628
|
+
CONSTRAINT "PK_AuditEvents_id" PRIMARY KEY ("id"))`);
|
|
8582
8629
|
}
|
|
8583
8630
|
async down(queryRunner) {
|
|
8584
|
-
await queryRunner.query(`DROP TABLE "
|
|
8585
|
-
await queryRunner.query(`
|
|
8586
|
-
await queryRunner.query(`
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
8593
|
-
)`);
|
|
8594
|
-
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
|
|
8595
|
-
SELECT "id", "label", "stringValue", "identityId"
|
|
8596
|
-
FROM "temporary_IdentityMetadata"`);
|
|
8597
|
-
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
8631
|
+
await queryRunner.query(`DROP TABLE "AuditEvents"`);
|
|
8632
|
+
await queryRunner.query(`DROP TYPE "public"."Party_correlation_type_enum"`);
|
|
8633
|
+
await queryRunner.query(`DROP TYPE "public"."System_correlation_id_type_enum"`);
|
|
8634
|
+
await queryRunner.query(`DROP TYPE "public"."Initiator_type_enum"`);
|
|
8635
|
+
await queryRunner.query(`DROP TYPE "public"."Action_type_enum"`);
|
|
8636
|
+
await queryRunner.query(`DROP TYPE "public"."Subsystem_type_enum"`);
|
|
8637
|
+
await queryRunner.query(`DROP TYPE "public"."System_enum"`);
|
|
8638
|
+
await queryRunner.query(`DROP TYPE "public"."Level_enum"`);
|
|
8598
8639
|
}
|
|
8599
8640
|
};
|
|
8600
8641
|
|
|
8601
|
-
// src/migrations/generic/
|
|
8642
|
+
// src/migrations/generic/5-CreateAuditEvents.ts
|
|
8602
8643
|
var debug16 = Debug16("sphereon:ssi-sdk:migrations");
|
|
8603
|
-
var
|
|
8644
|
+
var CreateAuditEvents1701635835330 = class {
|
|
8604
8645
|
static {
|
|
8605
|
-
__name(this, "
|
|
8646
|
+
__name(this, "CreateAuditEvents1701635835330");
|
|
8606
8647
|
}
|
|
8607
|
-
name = "
|
|
8648
|
+
name = "CreateAuditEvents1701635835330";
|
|
8608
8649
|
async up(queryRunner) {
|
|
8609
|
-
debug16("migration:
|
|
8650
|
+
debug16("migration: creating audit events tables");
|
|
8610
8651
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8611
8652
|
switch (dbType) {
|
|
8612
8653
|
case "postgres": {
|
|
8613
8654
|
debug16("using postgres migration file");
|
|
8614
|
-
const mig = new
|
|
8655
|
+
const mig = new CreateAuditEvents1701634812183();
|
|
8615
8656
|
await mig.up(queryRunner);
|
|
8616
8657
|
debug16("Migration statements executed");
|
|
8617
8658
|
return;
|
|
@@ -8620,7 +8661,7 @@ var CreateContacts1715761125000 = class {
|
|
|
8620
8661
|
case "expo":
|
|
8621
8662
|
case "react-native": {
|
|
8622
8663
|
debug16("using sqlite/react-native migration file");
|
|
8623
|
-
const mig = new
|
|
8664
|
+
const mig = new CreateAuditEvents1701634819487();
|
|
8624
8665
|
await mig.up(queryRunner);
|
|
8625
8666
|
debug16("Migration statements executed");
|
|
8626
8667
|
return;
|
|
@@ -8630,12 +8671,12 @@ var CreateContacts1715761125000 = class {
|
|
|
8630
8671
|
}
|
|
8631
8672
|
}
|
|
8632
8673
|
async down(queryRunner) {
|
|
8633
|
-
debug16("migration: reverting
|
|
8674
|
+
debug16("migration: reverting audit events tables");
|
|
8634
8675
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8635
8676
|
switch (dbType) {
|
|
8636
8677
|
case "postgres": {
|
|
8637
8678
|
debug16("using postgres migration file");
|
|
8638
|
-
const mig = new
|
|
8679
|
+
const mig = new CreateAuditEvents1701634812183();
|
|
8639
8680
|
await mig.down(queryRunner);
|
|
8640
8681
|
debug16("Migration statements executed");
|
|
8641
8682
|
return;
|
|
@@ -8644,7 +8685,7 @@ var CreateContacts1715761125000 = class {
|
|
|
8644
8685
|
case "expo":
|
|
8645
8686
|
case "react-native": {
|
|
8646
8687
|
debug16("using sqlite/react-native migration file");
|
|
8647
|
-
const mig = new
|
|
8688
|
+
const mig = new CreateAuditEvents1701634819487();
|
|
8648
8689
|
await mig.down(queryRunner);
|
|
8649
8690
|
debug16("Migration statements executed");
|
|
8650
8691
|
return;
|
|
@@ -8655,85 +8696,258 @@ var CreateContacts1715761125000 = class {
|
|
|
8655
8696
|
}
|
|
8656
8697
|
};
|
|
8657
8698
|
|
|
8658
|
-
// src/migrations/generic/
|
|
8699
|
+
// src/migrations/generic/6-CreateDigitalCredential.ts
|
|
8659
8700
|
import Debug17 from "debug";
|
|
8660
8701
|
|
|
8661
|
-
// src/migrations/postgres/
|
|
8662
|
-
var
|
|
8702
|
+
// src/migrations/postgres/1708525189001-CreateDigitalCredential.ts
|
|
8703
|
+
var CreateDigitalCredential1708525189001 = class {
|
|
8663
8704
|
static {
|
|
8664
|
-
__name(this, "
|
|
8705
|
+
__name(this, "CreateDigitalCredential1708525189001");
|
|
8665
8706
|
}
|
|
8666
|
-
name = "
|
|
8707
|
+
name = "CreateDigitalCredential1708525189001";
|
|
8667
8708
|
async up(queryRunner) {
|
|
8709
|
+
await queryRunner.query(`CREATE TYPE "digital_document_type" AS ENUM('VC', 'VP', 'C', 'P')`);
|
|
8710
|
+
await queryRunner.query(`CREATE TYPE "digital_regulation_type" AS ENUM('PID', 'QEAA', 'EAA', 'NON_REGULATED')`);
|
|
8711
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_document_format" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`);
|
|
8712
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_credential_role" AS ENUM('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR')`);
|
|
8713
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_correlation_type" AS ENUM('DID', 'KID', 'URL', 'X509_SAN')`);
|
|
8714
|
+
await queryRunner.query(`CREATE TYPE "digital_credential_state_type" AS ENUM('REVOKED', 'VERIFIED', 'EXPIRED')`);
|
|
8668
8715
|
await queryRunner.query(`
|
|
8669
|
-
CREATE TABLE "
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8716
|
+
CREATE TABLE "DigitalCredential" (
|
|
8717
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
8718
|
+
"parent_id" text,
|
|
8719
|
+
"document_type" "digital_document_type" NOT NULL,
|
|
8720
|
+
"regulation_type" "digital_regulation_type" NOT NULL DEFAULT 'NON_REGULATED'::"digital_regulation_type",
|
|
8721
|
+
"document_format" "digital_credential_document_format" NOT NULL,
|
|
8722
|
+
"credential_role" "digital_credential_credential_role" NOT NULL,
|
|
8723
|
+
"raw_document" text NOT NULL,
|
|
8724
|
+
"uniform_document" text NOT NULL,
|
|
8725
|
+
"credential_id" text,
|
|
8726
|
+
"hash" text NOT NULL,
|
|
8727
|
+
"kms_key_ref" text,
|
|
8728
|
+
"identifier_method" text,
|
|
8729
|
+
"issuer_correlation_type" "digital_credential_correlation_type" NOT NULL,
|
|
8730
|
+
"subject_correlation_type" "digital_credential_correlation_type",
|
|
8731
|
+
"issuer_correlation_id" text NOT NULL,
|
|
8732
|
+
"subject_correlation_id" text,
|
|
8733
|
+
"verified_state" "digital_credential_state_type",
|
|
8734
|
+
"issuer_signed" boolean,
|
|
8735
|
+
"rp_correlation_id" text,
|
|
8736
|
+
"rp_correlation_type" "digital_credential_correlation_type",
|
|
8737
|
+
"tenant_id" text,
|
|
8738
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8739
|
+
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8740
|
+
"presented_at" DATE,
|
|
8741
|
+
"valid_from" DATE,
|
|
8742
|
+
"valid_until" DATE,
|
|
8743
|
+
"verified_at" DATE,
|
|
8744
|
+
"revoked_at" DATE,
|
|
8745
|
+
PRIMARY KEY ("id"),
|
|
8746
|
+
UNIQUE ("hash", "credential_role")
|
|
8747
|
+
)
|
|
8748
|
+
`);
|
|
8682
8749
|
}
|
|
8683
8750
|
async down(queryRunner) {
|
|
8684
|
-
await queryRunner.query(`DROP TABLE "
|
|
8751
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
8752
|
+
await queryRunner.query(`DROP TYPE "digital_credential_state_type"`);
|
|
8753
|
+
await queryRunner.query(`DROP TYPE "digital_credential_correlation_type"`);
|
|
8754
|
+
await queryRunner.query(`DROP TYPE "digital_credential_document_format"`);
|
|
8755
|
+
await queryRunner.query(`DROP TYPE "digital_credential_credential_role"`);
|
|
8756
|
+
await queryRunner.query(`DROP TYPE "digital_regulation_type"`);
|
|
8757
|
+
await queryRunner.query(`DROP TYPE "digital_document_type"`);
|
|
8685
8758
|
}
|
|
8686
8759
|
};
|
|
8687
8760
|
|
|
8688
|
-
// src/migrations/sqlite/
|
|
8689
|
-
var
|
|
8761
|
+
// src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts
|
|
8762
|
+
var CreateDigitalCredential1708525189002 = class {
|
|
8763
|
+
static {
|
|
8764
|
+
__name(this, "CreateDigitalCredential1708525189002");
|
|
8765
|
+
}
|
|
8766
|
+
name = "CreateDigitalCredential1708525189002";
|
|
8767
|
+
async up(queryRunner) {
|
|
8768
|
+
await queryRunner.query(`
|
|
8769
|
+
CREATE TABLE "DigitalCredential" (
|
|
8770
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
8771
|
+
"parent_id" text,
|
|
8772
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
8773
|
+
"regulation_type" varchar CHECK( "regulation_type" IN ('PID', 'QEAA', 'EAA', 'NON_REGULATED') ) NOT NULL DEFAULT 'NON_REGULATED',
|
|
8774
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ) NOT NULL,
|
|
8775
|
+
"credential_role" varchar CHECK( "credential_role" IN ('ISSUER', 'VERIFIER', 'HOLDER', 'FEDERATION_TRUST_ANCHOR') ) NOT NULL,
|
|
8776
|
+
"raw_document" text NOT NULL,
|
|
8777
|
+
"uniform_document" text NOT NULL,
|
|
8778
|
+
"credential_id" text,
|
|
8779
|
+
"hash" text NOT NULL,
|
|
8780
|
+
"kms_key_ref" text,
|
|
8781
|
+
"identifier_method" text,
|
|
8782
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ) NOT NULL,
|
|
8783
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
8784
|
+
"issuer_correlation_id" text NOT NULL,
|
|
8785
|
+
"subject_correlation_id" text,
|
|
8786
|
+
"issuer_signed" boolean,
|
|
8787
|
+
"rp_correlation_id" text,
|
|
8788
|
+
"rp_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID', 'KID', 'URL', 'X509_SAN') ),
|
|
8789
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
|
|
8790
|
+
"tenant_id" text,
|
|
8791
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8792
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8793
|
+
"presented_at" datetime,
|
|
8794
|
+
"valid_from" datetime,
|
|
8795
|
+
"valid_until" datetime,
|
|
8796
|
+
"verified_at" datetime,
|
|
8797
|
+
"revoked_at" datetime,
|
|
8798
|
+
UNIQUE ("hash", "credential_role")
|
|
8799
|
+
)
|
|
8800
|
+
`);
|
|
8801
|
+
}
|
|
8802
|
+
async down(queryRunner) {
|
|
8803
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`);
|
|
8804
|
+
}
|
|
8805
|
+
};
|
|
8806
|
+
|
|
8807
|
+
// src/migrations/generic/6-CreateDigitalCredential.ts
|
|
8808
|
+
var debug17 = Debug17("sphereon:ssi-sdk:migrations");
|
|
8809
|
+
var CreateDigitalCredential1708525189000 = class {
|
|
8810
|
+
static {
|
|
8811
|
+
__name(this, "CreateDigitalCredential1708525189000");
|
|
8812
|
+
}
|
|
8813
|
+
name = "CreateDigitalCredential1708525189000";
|
|
8814
|
+
async up(queryRunner) {
|
|
8815
|
+
debug17("migration: creating DigitalCredential tables");
|
|
8816
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
8817
|
+
switch (dbType) {
|
|
8818
|
+
case "postgres": {
|
|
8819
|
+
debug17("using postgres migration file for DigitalCredential");
|
|
8820
|
+
const mig = new CreateDigitalCredential1708525189001();
|
|
8821
|
+
await mig.up(queryRunner);
|
|
8822
|
+
debug17("Postgres Migration statements for DigitalCredential executed");
|
|
8823
|
+
return;
|
|
8824
|
+
}
|
|
8825
|
+
case "sqlite":
|
|
8826
|
+
case "expo":
|
|
8827
|
+
case "react-native": {
|
|
8828
|
+
debug17("using sqlite/react-native migration file for DigitalCredential");
|
|
8829
|
+
const mig = new CreateDigitalCredential1708525189002();
|
|
8830
|
+
await mig.up(queryRunner);
|
|
8831
|
+
debug17("SQLite Migration statements for DigitalCredential executed");
|
|
8832
|
+
return;
|
|
8833
|
+
}
|
|
8834
|
+
default:
|
|
8835
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for UniformCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8836
|
+
}
|
|
8837
|
+
}
|
|
8838
|
+
async down(queryRunner) {
|
|
8839
|
+
debug17("migration: reverting DigitalCredential tables");
|
|
8840
|
+
const dbType = queryRunner.connection.driver.options.type;
|
|
8841
|
+
switch (dbType) {
|
|
8842
|
+
case "postgres": {
|
|
8843
|
+
debug17("using postgres migration file for DigitalCredential");
|
|
8844
|
+
const mig = new CreateDigitalCredential1708525189001();
|
|
8845
|
+
await mig.down(queryRunner);
|
|
8846
|
+
debug17("Postgres Migration statements for DigitalCredential reverted");
|
|
8847
|
+
return;
|
|
8848
|
+
}
|
|
8849
|
+
case "sqlite":
|
|
8850
|
+
case "expo":
|
|
8851
|
+
case "react-native": {
|
|
8852
|
+
debug17("using sqlite/react-native migration file for DigitalCredential");
|
|
8853
|
+
const mig = new CreateDigitalCredential1708525189002();
|
|
8854
|
+
await mig.down(queryRunner);
|
|
8855
|
+
debug17("SQLite Migration statements for DigitalCredential reverted");
|
|
8856
|
+
return;
|
|
8857
|
+
}
|
|
8858
|
+
default:
|
|
8859
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo, and postgres for DigitalCredential. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
};
|
|
8863
|
+
|
|
8864
|
+
// src/migrations/generic/7-CreateMachineStateStore.ts
|
|
8865
|
+
import Debug18 from "debug";
|
|
8866
|
+
|
|
8867
|
+
// src/migrations/postgres/1708797018115-CreateMachineStateStore.ts
|
|
8868
|
+
var CreateMachineStateStore1708797018115 = class {
|
|
8869
|
+
static {
|
|
8870
|
+
__name(this, "CreateMachineStateStore1708797018115");
|
|
8871
|
+
}
|
|
8872
|
+
name = "CreateMachineStateStore1708797018115";
|
|
8873
|
+
async up(queryRunner) {
|
|
8874
|
+
await queryRunner.query(`
|
|
8875
|
+
CREATE TABLE "MachineStateInfoEntity" (
|
|
8876
|
+
"instance_id" text NOT NULL,
|
|
8877
|
+
"session_id" text,
|
|
8878
|
+
"latest_state_name" text,
|
|
8879
|
+
"machine_name" text NOT NULL,
|
|
8880
|
+
"latest_event_type" text NOT NULL,
|
|
8881
|
+
"state" text NOT NULL,
|
|
8882
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8883
|
+
"updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
8884
|
+
"updated_count" integer NOT NULL DEFAULT 0,
|
|
8885
|
+
"expires_at" TIMESTAMP,
|
|
8886
|
+
"completed_at" TIMESTAMP,
|
|
8887
|
+
"tenant_id" text,
|
|
8888
|
+
CONSTRAINT "PK_MachineStateInfoEntity_id" PRIMARY KEY ("instance_id")
|
|
8889
|
+
)
|
|
8890
|
+
`);
|
|
8891
|
+
}
|
|
8892
|
+
async down(queryRunner) {
|
|
8893
|
+
await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
|
|
8894
|
+
}
|
|
8895
|
+
};
|
|
8896
|
+
|
|
8897
|
+
// src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts
|
|
8898
|
+
var CreateMachineStateStore1708796002272 = class {
|
|
8690
8899
|
static {
|
|
8691
|
-
__name(this, "
|
|
8900
|
+
__name(this, "CreateMachineStateStore1708796002272");
|
|
8692
8901
|
}
|
|
8693
|
-
name = "
|
|
8902
|
+
name = "CreateMachineStateStore1708796002272";
|
|
8694
8903
|
async up(queryRunner) {
|
|
8695
|
-
await queryRunner.query(`
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8904
|
+
await queryRunner.query(`
|
|
8905
|
+
CREATE TABLE "MachineStateInfoEntity" (
|
|
8906
|
+
"instance_id" varchar PRIMARY KEY NOT NULL,
|
|
8907
|
+
"session_id" varchar,
|
|
8908
|
+
"machine_name" varchar NOT NULL,
|
|
8909
|
+
"latest_state_name" varchar,
|
|
8910
|
+
"latest_event_type" varchar NOT NULL,
|
|
8911
|
+
"state" text NOT NULL,
|
|
8912
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8913
|
+
"updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
8914
|
+
"updated_count" integer NOT NULL DEFAULT 0,
|
|
8915
|
+
"expires_at" datetime,
|
|
8916
|
+
"completed_at" datetime,
|
|
8917
|
+
"tenant_id" varchar
|
|
8918
|
+
)
|
|
8919
|
+
`);
|
|
8706
8920
|
}
|
|
8707
8921
|
async down(queryRunner) {
|
|
8708
|
-
await queryRunner.query(`DROP TABLE "
|
|
8922
|
+
await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`);
|
|
8709
8923
|
}
|
|
8710
8924
|
};
|
|
8711
8925
|
|
|
8712
|
-
// src/migrations/generic/
|
|
8713
|
-
var
|
|
8714
|
-
var
|
|
8926
|
+
// src/migrations/generic/7-CreateMachineStateStore.ts
|
|
8927
|
+
var debug18 = Debug18("sphereon:ssi-sdk:migrations");
|
|
8928
|
+
var CreateMachineStateStore1708098041262 = class {
|
|
8715
8929
|
static {
|
|
8716
|
-
__name(this, "
|
|
8930
|
+
__name(this, "CreateMachineStateStore1708098041262");
|
|
8717
8931
|
}
|
|
8718
|
-
name = "
|
|
8932
|
+
name = "CreateMachineStateStore1708098041262";
|
|
8719
8933
|
async up(queryRunner) {
|
|
8720
|
-
|
|
8934
|
+
debug18("migration: creating machine state tables");
|
|
8721
8935
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8722
8936
|
switch (dbType) {
|
|
8723
8937
|
case "postgres": {
|
|
8724
|
-
|
|
8725
|
-
const mig = new
|
|
8938
|
+
debug18("using postgres migration file");
|
|
8939
|
+
const mig = new CreateMachineStateStore1708797018115();
|
|
8726
8940
|
await mig.up(queryRunner);
|
|
8727
|
-
|
|
8941
|
+
debug18("Migration statements executed");
|
|
8728
8942
|
return;
|
|
8729
8943
|
}
|
|
8730
8944
|
case "sqlite":
|
|
8731
8945
|
case "expo":
|
|
8732
8946
|
case "react-native": {
|
|
8733
|
-
|
|
8734
|
-
const mig = new
|
|
8947
|
+
debug18("using sqlite/react-native migration file");
|
|
8948
|
+
const mig = new CreateMachineStateStore1708796002272();
|
|
8735
8949
|
await mig.up(queryRunner);
|
|
8736
|
-
|
|
8950
|
+
debug18("Migration statements executed");
|
|
8737
8951
|
return;
|
|
8738
8952
|
}
|
|
8739
8953
|
default:
|
|
@@ -8741,23 +8955,23 @@ var CreatePresentationDefinitions1716533767523 = class {
|
|
|
8741
8955
|
}
|
|
8742
8956
|
}
|
|
8743
8957
|
async down(queryRunner) {
|
|
8744
|
-
|
|
8958
|
+
debug18("migration: reverting machine state tables");
|
|
8745
8959
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8746
8960
|
switch (dbType) {
|
|
8747
8961
|
case "postgres": {
|
|
8748
|
-
|
|
8749
|
-
const mig = new
|
|
8962
|
+
debug18("using postgres migration file");
|
|
8963
|
+
const mig = new CreateMachineStateStore1708797018115();
|
|
8750
8964
|
await mig.down(queryRunner);
|
|
8751
|
-
|
|
8965
|
+
debug18("Migration statements executed");
|
|
8752
8966
|
return;
|
|
8753
8967
|
}
|
|
8754
8968
|
case "sqlite":
|
|
8755
8969
|
case "expo":
|
|
8756
8970
|
case "react-native": {
|
|
8757
|
-
|
|
8758
|
-
const mig = new
|
|
8971
|
+
debug18("using sqlite/react-native migration file");
|
|
8972
|
+
const mig = new CreateMachineStateStore1708796002272();
|
|
8759
8973
|
await mig.down(queryRunner);
|
|
8760
|
-
|
|
8974
|
+
debug18("Migration statements executed");
|
|
8761
8975
|
return;
|
|
8762
8976
|
}
|
|
8763
8977
|
default:
|
|
@@ -8766,108 +8980,145 @@ var CreatePresentationDefinitions1716533767523 = class {
|
|
|
8766
8980
|
}
|
|
8767
8981
|
};
|
|
8768
8982
|
|
|
8769
|
-
// src/migrations/generic/
|
|
8770
|
-
import
|
|
8983
|
+
// src/migrations/generic/8-CreateContacts.ts
|
|
8984
|
+
import Debug19 from "debug";
|
|
8771
8985
|
|
|
8772
|
-
// src/migrations/postgres/
|
|
8773
|
-
var
|
|
8986
|
+
// src/migrations/postgres/1710438363001-CreateContacts.ts
|
|
8987
|
+
var CreateContacts1710438363001 = class {
|
|
8774
8988
|
static {
|
|
8775
|
-
__name(this, "
|
|
8989
|
+
__name(this, "CreateContacts1710438363001");
|
|
8776
8990
|
}
|
|
8777
|
-
name = "
|
|
8991
|
+
name = "CreateContacts1710438363001";
|
|
8778
8992
|
async up(queryRunner) {
|
|
8779
|
-
await queryRunner.query(`
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
`);
|
|
8993
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`);
|
|
8994
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`);
|
|
8995
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`);
|
|
8996
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`);
|
|
8997
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`);
|
|
8998
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`);
|
|
8999
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`);
|
|
9000
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`);
|
|
9001
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`);
|
|
9002
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`);
|
|
9003
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`);
|
|
9004
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`);
|
|
9005
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`);
|
|
9006
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`);
|
|
9007
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`);
|
|
9008
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`);
|
|
9009
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`);
|
|
9010
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`);
|
|
8783
9011
|
}
|
|
8784
9012
|
async down(queryRunner) {
|
|
8785
|
-
await queryRunner.query(`
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
`);
|
|
9013
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
|
|
9014
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
|
|
9015
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
|
|
9016
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
|
|
9017
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
|
|
9018
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
|
|
9019
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
|
|
9020
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
|
|
9021
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
|
|
9022
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
|
|
9023
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
|
|
9024
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
|
|
9025
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
|
|
9026
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
|
|
9027
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
|
|
9028
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
|
|
9029
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
|
|
9030
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
|
|
8789
9031
|
}
|
|
8790
9032
|
};
|
|
8791
9033
|
|
|
8792
|
-
// src/migrations/sqlite/
|
|
8793
|
-
var
|
|
9034
|
+
// src/migrations/sqlite/1710438363002-CreateContacts.ts
|
|
9035
|
+
var CreateContacts1710438363002 = class {
|
|
8794
9036
|
static {
|
|
8795
|
-
__name(this, "
|
|
9037
|
+
__name(this, "CreateContacts1710438363002");
|
|
8796
9038
|
}
|
|
8797
|
-
name = "
|
|
9039
|
+
name = "CreateContacts1710438363002";
|
|
8798
9040
|
async up(queryRunner) {
|
|
8799
|
-
await queryRunner.query(`
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
await queryRunner.query(`
|
|
8815
|
-
|
|
8816
|
-
await queryRunner.query(`
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
9041
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" text`);
|
|
9042
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" text`);
|
|
9043
|
+
await queryRunner.query(`CREATE TABLE "temporary_Identity" (
|
|
9044
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
9045
|
+
"alias" varchar(255) NOT NULL,
|
|
9046
|
+
"roles" text NOT NULL,
|
|
9047
|
+
"origin" text NOT NULL,
|
|
9048
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
9049
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
9050
|
+
"partyId" varchar,
|
|
9051
|
+
"owner_id" text,
|
|
9052
|
+
"tenant_id" text,
|
|
9053
|
+
CONSTRAINT "UQ_Identity_alias" UNIQUE ("alias"),
|
|
9054
|
+
CONSTRAINT "FK_Identity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
|
9055
|
+
)`);
|
|
9056
|
+
await queryRunner.query(`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "partyId", "owner_id", "tenant_id", "origin")
|
|
9057
|
+
SELECT "id", "alias", "roles", 'EXTERNAL' as "origin", "created_at", "last_updated_at", "partyId", NULL as "owner_id", NULL as "tenant_id" FROM "Identity"`);
|
|
9058
|
+
await queryRunner.query(`DROP TABLE "Identity"`);
|
|
9059
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`);
|
|
9060
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" text`);
|
|
9061
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" text`);
|
|
9062
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" text`);
|
|
9063
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" text`);
|
|
9064
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" text`);
|
|
9065
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" text`);
|
|
9066
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" text`);
|
|
9067
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" text`);
|
|
9068
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" text`);
|
|
9069
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" text`);
|
|
9070
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" text`);
|
|
9071
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" text`);
|
|
9072
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" text`);
|
|
9073
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" text`);
|
|
8820
9074
|
}
|
|
8821
9075
|
async down(queryRunner) {
|
|
8822
|
-
await queryRunner.query(`
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
await queryRunner.query(`
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
await queryRunner.query(`
|
|
8838
|
-
await queryRunner.query(`ALTER TABLE "
|
|
8839
|
-
await queryRunner.query(`
|
|
8840
|
-
CREATE UNIQUE INDEX "IDX_CredentialClaimsEntity_credentialLocaleBranding_locale"
|
|
8841
|
-
ON "CredentialClaims" ("credentialLocaleBrandingId", "key")
|
|
8842
|
-
`);
|
|
9076
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`);
|
|
9077
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`);
|
|
9078
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`);
|
|
9079
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`);
|
|
9080
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`);
|
|
9081
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`);
|
|
9082
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`);
|
|
9083
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`);
|
|
9084
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`);
|
|
9085
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`);
|
|
9086
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`);
|
|
9087
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`);
|
|
9088
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`);
|
|
9089
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`);
|
|
9090
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`);
|
|
9091
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`);
|
|
9092
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`);
|
|
9093
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`);
|
|
8843
9094
|
}
|
|
8844
9095
|
};
|
|
8845
9096
|
|
|
8846
|
-
// src/migrations/generic/
|
|
8847
|
-
var
|
|
8848
|
-
var
|
|
9097
|
+
// src/migrations/generic/8-CreateContacts.ts
|
|
9098
|
+
var debug19 = Debug19("sphereon:ssi-sdk:migrations");
|
|
9099
|
+
var CreateContacts1708525189000 = class {
|
|
8849
9100
|
static {
|
|
8850
|
-
__name(this, "
|
|
9101
|
+
__name(this, "CreateContacts1708525189000");
|
|
8851
9102
|
}
|
|
8852
|
-
name = "
|
|
9103
|
+
name = "CreateContacts1708525189000";
|
|
8853
9104
|
async up(queryRunner) {
|
|
8854
|
-
|
|
9105
|
+
debug19("migration: updating contact tables");
|
|
8855
9106
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8856
9107
|
switch (dbType) {
|
|
8857
9108
|
case "postgres": {
|
|
8858
|
-
|
|
8859
|
-
const mig = new
|
|
9109
|
+
debug19("using postgres migration file");
|
|
9110
|
+
const mig = new CreateContacts1710438363001();
|
|
8860
9111
|
await mig.up(queryRunner);
|
|
8861
|
-
|
|
9112
|
+
debug19("Migration statements executed");
|
|
8862
9113
|
return;
|
|
8863
9114
|
}
|
|
8864
9115
|
case "sqlite":
|
|
8865
9116
|
case "expo":
|
|
8866
9117
|
case "react-native": {
|
|
8867
|
-
|
|
8868
|
-
const mig = new
|
|
9118
|
+
debug19("using sqlite/react-native migration file");
|
|
9119
|
+
const mig = new CreateContacts1710438363002();
|
|
8869
9120
|
await mig.up(queryRunner);
|
|
8870
|
-
|
|
9121
|
+
debug19("Migration statements executed");
|
|
8871
9122
|
return;
|
|
8872
9123
|
}
|
|
8873
9124
|
default:
|
|
@@ -8875,23 +9126,23 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
|
|
|
8875
9126
|
}
|
|
8876
9127
|
}
|
|
8877
9128
|
async down(queryRunner) {
|
|
8878
|
-
|
|
9129
|
+
debug19("migration: reverting machine state tables");
|
|
8879
9130
|
const dbType = queryRunner.connection.driver.options.type;
|
|
8880
9131
|
switch (dbType) {
|
|
8881
9132
|
case "postgres": {
|
|
8882
|
-
|
|
8883
|
-
const mig = new
|
|
9133
|
+
debug19("using postgres migration file");
|
|
9134
|
+
const mig = new CreateContacts1710438363001();
|
|
8884
9135
|
await mig.down(queryRunner);
|
|
8885
|
-
|
|
9136
|
+
debug19("Migration statements executed");
|
|
8886
9137
|
return;
|
|
8887
9138
|
}
|
|
8888
9139
|
case "sqlite":
|
|
8889
9140
|
case "expo":
|
|
8890
9141
|
case "react-native": {
|
|
8891
|
-
|
|
8892
|
-
const mig = new
|
|
9142
|
+
debug19("using sqlite/react-native migration file");
|
|
9143
|
+
const mig = new CreateContacts1710438363002();
|
|
8893
9144
|
await mig.down(queryRunner);
|
|
8894
|
-
|
|
9145
|
+
debug19("Migration statements executed");
|
|
8895
9146
|
return;
|
|
8896
9147
|
}
|
|
8897
9148
|
default:
|
|
@@ -8900,222 +9151,171 @@ var FixCredentialClaimsReferencesUuid1741895822987 = class {
|
|
|
8900
9151
|
}
|
|
8901
9152
|
};
|
|
8902
9153
|
|
|
8903
|
-
// src/migrations/generic/
|
|
8904
|
-
import
|
|
9154
|
+
// src/migrations/generic/9-CreateContacts.ts
|
|
9155
|
+
import Debug20 from "debug";
|
|
8905
9156
|
|
|
8906
|
-
// src/migrations/postgres/
|
|
8907
|
-
var
|
|
9157
|
+
// src/migrations/postgres/1715761125001-CreateContacts.ts
|
|
9158
|
+
var CreateContacts1715761125001 = class {
|
|
8908
9159
|
static {
|
|
8909
|
-
__name(this, "
|
|
9160
|
+
__name(this, "CreateContacts1715761125001");
|
|
8910
9161
|
}
|
|
8911
|
-
name = "
|
|
9162
|
+
name = "CreateContacts1715761125001";
|
|
8912
9163
|
async up(queryRunner) {
|
|
8913
|
-
await queryRunner.query(`ALTER TABLE "
|
|
8914
|
-
await queryRunner.query(`
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
9164
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
|
|
9165
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
9166
|
+
(
|
|
9167
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
9168
|
+
"label" character varying(255) NOT NULL,
|
|
9169
|
+
"valueType" character varying NOT NULL,
|
|
9170
|
+
"stringValue" text,
|
|
9171
|
+
"numberValue" double precision,
|
|
9172
|
+
"dateValue" TIMESTAMP,
|
|
9173
|
+
"boolValue" boolean,
|
|
9174
|
+
"identityId" uuid,
|
|
9175
|
+
CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
9176
|
+
)`);
|
|
9177
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
|
|
9178
|
+
SELECT "id", "label", 'string', "value", "identityId"
|
|
9179
|
+
FROM "temporary_IdentityMetadata"`);
|
|
9180
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
9181
|
+
await queryRunner.query(`CREATE TABLE "ContactMetadata"
|
|
9182
|
+
(
|
|
9183
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
9184
|
+
"label" character varying(255) NOT NULL,
|
|
9185
|
+
"valueType" character varying NOT NULL,
|
|
9186
|
+
"stringValue" text,
|
|
9187
|
+
"numberValue" double precision,
|
|
9188
|
+
"dateValue" TIMESTAMP,
|
|
9189
|
+
"boolValue" boolean,
|
|
9190
|
+
"contactId" uuid,
|
|
9191
|
+
CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
|
|
9192
|
+
)`);
|
|
8925
9193
|
}
|
|
8926
9194
|
async down(queryRunner) {
|
|
8927
|
-
await queryRunner.query(`
|
|
8928
|
-
await queryRunner.query(`ALTER TABLE "
|
|
8929
|
-
await queryRunner.query(`
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
await queryRunner.query(`
|
|
8938
|
-
|
|
9195
|
+
await queryRunner.query(`DROP TABLE "ContactMetadata"`);
|
|
9196
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
|
|
9197
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
9198
|
+
(
|
|
9199
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
9200
|
+
"label" character varying(255) NOT NULL,
|
|
9201
|
+
"value" character varying(255) NOT NULL,
|
|
9202
|
+
"identityId" uuid,
|
|
9203
|
+
CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
9204
|
+
)`);
|
|
9205
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
|
|
9206
|
+
SELECT "id", "label", "stringValue", "identityId"
|
|
9207
|
+
FROM "temporary_IdentityMetadata"`);
|
|
9208
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
8939
9209
|
}
|
|
8940
9210
|
};
|
|
8941
9211
|
|
|
8942
|
-
// src/migrations/sqlite/
|
|
8943
|
-
var
|
|
9212
|
+
// src/migrations/sqlite/1715761125002-CreateContacts.ts
|
|
9213
|
+
var CreateContacts1715761125002 = class {
|
|
8944
9214
|
static {
|
|
8945
|
-
__name(this, "
|
|
9215
|
+
__name(this, "CreateContacts1715761125002");
|
|
8946
9216
|
}
|
|
8947
|
-
name = "
|
|
9217
|
+
name = "CreateContacts1715761125002";
|
|
8948
9218
|
async up(queryRunner) {
|
|
8949
|
-
await queryRunner.query(`
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
8978
|
-
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
8979
|
-
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
8980
|
-
FROM "StatusList"
|
|
8981
|
-
`);
|
|
8982
|
-
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
8983
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
8984
|
-
await queryRunner.query(`
|
|
8985
|
-
CREATE TABLE "temporary_StatusListEntry" (
|
|
8986
|
-
"statusListId" varchar NOT NULL,
|
|
8987
|
-
"statusListIndex" integer NOT NULL,
|
|
8988
|
-
"credentialId" text,
|
|
8989
|
-
"credentialHash" varchar(128),
|
|
8990
|
-
"correlationId" varchar(255),
|
|
8991
|
-
"value" varchar(50),
|
|
8992
|
-
"type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
|
|
8993
|
-
"statusPurpose" varchar,
|
|
8994
|
-
"bitsPerStatus" integer DEFAULT (1),
|
|
8995
|
-
"statusMessage" text,
|
|
8996
|
-
"statusReference" text,
|
|
8997
|
-
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
8998
|
-
)
|
|
8999
|
-
`);
|
|
9000
|
-
await queryRunner.query(`
|
|
9001
|
-
INSERT INTO "temporary_StatusListEntry"(
|
|
9002
|
-
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
9003
|
-
"correlationId", "value", "type"
|
|
9004
|
-
)
|
|
9005
|
-
SELECT
|
|
9006
|
-
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
9007
|
-
"correlationId", "value", 'StatusListEntryEntity'
|
|
9008
|
-
FROM "StatusListEntry"
|
|
9009
|
-
`);
|
|
9010
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
9011
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
9219
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
|
|
9220
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
9221
|
+
(
|
|
9222
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
9223
|
+
"label" varchar(255) NOT NULL,
|
|
9224
|
+
"valueType" varchar NOT NULL,
|
|
9225
|
+
"stringValue" varchar(255),
|
|
9226
|
+
"numberValue" double,
|
|
9227
|
+
"dateValue" datetime,
|
|
9228
|
+
"boolValue" boolean,
|
|
9229
|
+
"identityId" varchar,
|
|
9230
|
+
FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE)`);
|
|
9231
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
|
|
9232
|
+
SELECT "id", "label", 'string', "value", "identityId"
|
|
9233
|
+
FROM "temporary_IdentityMetadata"
|
|
9234
|
+
`);
|
|
9235
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
9236
|
+
await queryRunner.query(`CREATE TABLE "ContactMetadata"
|
|
9237
|
+
(
|
|
9238
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
9239
|
+
"label" varchar(255) NOT NULL,
|
|
9240
|
+
"valueType" varchar NOT NULL,
|
|
9241
|
+
"stringValue" text,
|
|
9242
|
+
"numberValue" double,
|
|
9243
|
+
"dateValue" datetime,
|
|
9244
|
+
"boolValue" boolean,
|
|
9245
|
+
"contactId" varchar,
|
|
9246
|
+
FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE)`);
|
|
9012
9247
|
}
|
|
9013
9248
|
async down(queryRunner) {
|
|
9014
|
-
await queryRunner.query(`
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
`)
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
"correlationId", "value"
|
|
9029
|
-
)
|
|
9030
|
-
SELECT
|
|
9031
|
-
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
9032
|
-
"correlationId", "value"
|
|
9033
|
-
FROM "StatusListEntry"
|
|
9034
|
-
WHERE "type" = 'StatusListEntryEntity'
|
|
9035
|
-
`);
|
|
9036
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`);
|
|
9037
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`);
|
|
9038
|
-
await queryRunner.query(`
|
|
9039
|
-
CREATE TABLE "temporary_StatusList" (
|
|
9040
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
9041
|
-
"correlationId" varchar NOT NULL,
|
|
9042
|
-
"length" integer NOT NULL,
|
|
9043
|
-
"issuer" text NOT NULL,
|
|
9044
|
-
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
9045
|
-
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
9046
|
-
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
9047
|
-
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
|
|
9048
|
-
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
9049
|
-
"statusPurpose" varchar,
|
|
9050
|
-
"statusListCredential" text,
|
|
9051
|
-
"bitsPerStatus" integer,
|
|
9052
|
-
"expiresAt" datetime,
|
|
9053
|
-
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
9054
|
-
)
|
|
9055
|
-
`);
|
|
9056
|
-
await queryRunner.query(`
|
|
9057
|
-
INSERT INTO "temporary_StatusList"(
|
|
9058
|
-
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
9059
|
-
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
9060
|
-
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
9061
|
-
)
|
|
9062
|
-
SELECT
|
|
9063
|
-
"id", "correlationId", "length", "issuer",
|
|
9064
|
-
CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
9065
|
-
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
9066
|
-
"statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
|
|
9067
|
-
FROM "StatusList"
|
|
9068
|
-
`);
|
|
9069
|
-
await queryRunner.query(`DROP TABLE "StatusList"`);
|
|
9070
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`);
|
|
9249
|
+
await queryRunner.query(`DROP TABLE "ContactMetadata"`);
|
|
9250
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`);
|
|
9251
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
9252
|
+
(
|
|
9253
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
9254
|
+
"label" varchar(255) NOT NULL,
|
|
9255
|
+
"value" varchar(255) NOT NULL,
|
|
9256
|
+
"identityId" varchar,
|
|
9257
|
+
FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
9258
|
+
)`);
|
|
9259
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
|
|
9260
|
+
SELECT "id", "label", "stringValue", "identityId"
|
|
9261
|
+
FROM "temporary_IdentityMetadata"`);
|
|
9262
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`);
|
|
9071
9263
|
}
|
|
9072
9264
|
};
|
|
9073
9265
|
|
|
9074
|
-
// src/migrations/generic/
|
|
9075
|
-
var
|
|
9076
|
-
var
|
|
9266
|
+
// src/migrations/generic/9-CreateContacts.ts
|
|
9267
|
+
var debug20 = Debug20("sphereon:ssi-sdk:migrations");
|
|
9268
|
+
var CreateContacts1715761125000 = class {
|
|
9077
9269
|
static {
|
|
9078
|
-
__name(this, "
|
|
9270
|
+
__name(this, "CreateContacts1715761125000");
|
|
9079
9271
|
}
|
|
9080
|
-
name = "
|
|
9272
|
+
name = "CreateContacts1715761125000";
|
|
9081
9273
|
async up(queryRunner) {
|
|
9082
|
-
|
|
9274
|
+
debug20("migration: updating contact tables");
|
|
9083
9275
|
const dbType = queryRunner.connection.driver.options.type;
|
|
9084
9276
|
switch (dbType) {
|
|
9085
9277
|
case "postgres": {
|
|
9086
|
-
|
|
9278
|
+
debug20("using postgres migration file");
|
|
9279
|
+
const mig = new CreateContacts1715761125001();
|
|
9087
9280
|
await mig.up(queryRunner);
|
|
9281
|
+
debug20("Migration statements executed");
|
|
9088
9282
|
return;
|
|
9089
9283
|
}
|
|
9090
9284
|
case "sqlite":
|
|
9091
9285
|
case "expo":
|
|
9092
9286
|
case "react-native": {
|
|
9093
|
-
|
|
9287
|
+
debug20("using sqlite/react-native migration file");
|
|
9288
|
+
const mig = new CreateContacts1715761125002();
|
|
9094
9289
|
await mig.up(queryRunner);
|
|
9290
|
+
debug20("Migration statements executed");
|
|
9095
9291
|
return;
|
|
9096
9292
|
}
|
|
9097
9293
|
default:
|
|
9098
|
-
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
|
|
9294
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
9099
9295
|
}
|
|
9100
9296
|
}
|
|
9101
9297
|
async down(queryRunner) {
|
|
9102
|
-
|
|
9298
|
+
debug20("migration: reverting machine state tables");
|
|
9103
9299
|
const dbType = queryRunner.connection.driver.options.type;
|
|
9104
9300
|
switch (dbType) {
|
|
9105
9301
|
case "postgres": {
|
|
9106
|
-
|
|
9302
|
+
debug20("using postgres migration file");
|
|
9303
|
+
const mig = new CreateContacts1715761125001();
|
|
9107
9304
|
await mig.down(queryRunner);
|
|
9305
|
+
debug20("Migration statements executed");
|
|
9108
9306
|
return;
|
|
9109
9307
|
}
|
|
9110
9308
|
case "sqlite":
|
|
9111
9309
|
case "expo":
|
|
9112
9310
|
case "react-native": {
|
|
9113
|
-
|
|
9311
|
+
debug20("using sqlite/react-native migration file");
|
|
9312
|
+
const mig = new CreateContacts1715761125002();
|
|
9114
9313
|
await mig.down(queryRunner);
|
|
9314
|
+
debug20("Migration statements executed");
|
|
9115
9315
|
return;
|
|
9116
9316
|
}
|
|
9117
9317
|
default:
|
|
9118
|
-
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`);
|
|
9318
|
+
return Promise.reject(`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`);
|
|
9119
9319
|
}
|
|
9120
9320
|
}
|
|
9121
9321
|
};
|
|
@@ -9133,6 +9333,7 @@ var DataStoreIssuanceBrandingMigrations = [
|
|
|
9133
9333
|
];
|
|
9134
9334
|
var DataStoreStatusListMigrations = [
|
|
9135
9335
|
CreateStatusList1693866470000,
|
|
9336
|
+
AddBitstringStatusListEnum1741895823000,
|
|
9136
9337
|
CreateBitstringStatusList1741895823000
|
|
9137
9338
|
];
|
|
9138
9339
|
var DataStoreEventLoggerMigrations = [
|
|
@@ -9145,7 +9346,8 @@ var DataStoreMachineStateMigrations = [
|
|
|
9145
9346
|
CreateMachineStateStore1708098041262
|
|
9146
9347
|
];
|
|
9147
9348
|
var DataStorePresentationDefinitionMigrations = [
|
|
9148
|
-
CreatePresentationDefinitions1716533767523
|
|
9349
|
+
CreatePresentationDefinitions1716533767523,
|
|
9350
|
+
UpdatePresentationDefinitionItemNullable1741895824000
|
|
9149
9351
|
];
|
|
9150
9352
|
var DataStoreMigrations = [
|
|
9151
9353
|
...DataStoreContactMigrations,
|
|
@@ -9384,7 +9586,6 @@ export {
|
|
|
9384
9586
|
CredentialCorrelationType,
|
|
9385
9587
|
CredentialDocumentFormat,
|
|
9386
9588
|
CredentialLocaleBrandingEntity,
|
|
9387
|
-
CredentialRole,
|
|
9388
9589
|
CredentialStateType,
|
|
9389
9590
|
DataStoreContactEntities,
|
|
9390
9591
|
DataStoreContactMigrations,
|