@sphereon/ssi-sdk.data-store 0.23.5-unstable.88 → 0.24.0
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/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/index.d.ts +0 -2
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +1 -4
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/contact.entities.test.ts +2542 -2542
- package/src/__tests__/contact.store.test.ts +2471 -2471
- package/src/__tests__/digitalCredential.entities.test.ts +254 -254
- package/src/__tests__/digitalCredential.store.test.ts +294 -294
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
- package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
- package/src/__tests__/machineState.entities.test.ts +51 -51
- package/src/__tests__/machineState.store.test.ts +174 -174
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +723 -723
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
- package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
- package/src/entities/contact/BaseContactEntity.ts +39 -39
- package/src/entities/contact/ConnectionEntity.ts +29 -29
- package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
- package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
- package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
- package/src/entities/contact/IdentityEntity.ts +97 -97
- package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
- package/src/entities/contact/NaturalPersonEntity.ts +38 -38
- package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
- package/src/entities/contact/OrganizationEntity.ts +34 -34
- package/src/entities/contact/PartyEntity.ts +110 -110
- package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
- package/src/entities/contact/PartyTypeEntity.ts +62 -62
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
- package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +141 -154
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/index.ts +33 -36
- package/src/migrations/index.ts +9 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/statusList/StatusListStore.ts +237 -237
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +237 -237
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
- package/src/types/digitalCredential/digitalCredential.ts +46 -46
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +10 -12
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +385 -385
- package/src/utils/digitalCredential/MappingUtils.ts +122 -122
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
- package/dist/pd/AbstractPDStore.d.ts +0 -10
- package/dist/pd/AbstractPDStore.d.ts.map +0 -1
- package/dist/pd/AbstractPDStore.js +0 -7
- package/dist/pd/AbstractPDStore.js.map +0 -1
- package/dist/pd/PDStore.d.ts +0 -14
- package/dist/pd/PDStore.d.ts.map +0 -1
- package/dist/pd/PDStore.js +0 -90
- package/dist/pd/PDStore.js.map +0 -1
- package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
- package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
- package/dist/types/pd/IAbstractPDStore.js +0 -3
- package/dist/types/pd/IAbstractPDStore.js.map +0 -1
- package/dist/types/pd/pd.d.ts +0 -15
- package/dist/types/pd/pd.d.ts.map +0 -1
- package/dist/types/pd/pd.js +0 -3
- package/dist/types/pd/pd.js.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
- package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
- package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
- package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
- package/src/pd/AbstractPDStore.ts +0 -10
- package/src/pd/PDStore.ts +0 -103
- package/src/types/pd/IAbstractPDStore.ts +0 -19
- package/src/types/pd/pd.ts +0 -16
- package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateContacts1690925872693 implements MigrationInterface {
|
|
4
|
-
name = 'CreateContacts1690925872693'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
await queryRunner.query(
|
|
8
|
-
`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"))`,
|
|
9
|
-
)
|
|
10
|
-
await queryRunner.query(
|
|
11
|
-
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`,
|
|
12
|
-
)
|
|
13
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
14
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
15
|
-
await queryRunner.query(
|
|
16
|
-
`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"))`,
|
|
17
|
-
)
|
|
18
|
-
await queryRunner.query(
|
|
19
|
-
`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"`,
|
|
20
|
-
)
|
|
21
|
-
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
22
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
23
|
-
await queryRunner.query(
|
|
24
|
-
`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"))`,
|
|
25
|
-
)
|
|
26
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
27
|
-
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
28
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
29
|
-
await queryRunner.query(
|
|
30
|
-
`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"))`,
|
|
31
|
-
)
|
|
32
|
-
await queryRunner.query(
|
|
33
|
-
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`,
|
|
34
|
-
)
|
|
35
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
36
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
37
|
-
await queryRunner.query(
|
|
38
|
-
`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"))`,
|
|
39
|
-
)
|
|
40
|
-
await queryRunner.query(
|
|
41
|
-
`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"`,
|
|
42
|
-
)
|
|
43
|
-
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
44
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
45
|
-
await queryRunner.query(
|
|
46
|
-
`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"))`,
|
|
47
|
-
)
|
|
48
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
49
|
-
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
50
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
51
|
-
await queryRunner.query(
|
|
52
|
-
`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 DEFAULT 'EXTERNAL', "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"))`,
|
|
53
|
-
)
|
|
54
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`)
|
|
55
|
-
await queryRunner.query(
|
|
56
|
-
`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"))`,
|
|
57
|
-
)
|
|
58
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`)
|
|
59
|
-
await queryRunner.query(
|
|
60
|
-
`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')))`,
|
|
61
|
-
)
|
|
62
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
|
|
63
|
-
await queryRunner.query(
|
|
64
|
-
`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)`,
|
|
65
|
-
)
|
|
66
|
-
await queryRunner.query(
|
|
67
|
-
`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"))`,
|
|
68
|
-
)
|
|
69
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`)
|
|
70
|
-
await queryRunner.query(
|
|
71
|
-
`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)`,
|
|
72
|
-
)
|
|
73
|
-
await queryRunner.query(
|
|
74
|
-
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`,
|
|
75
|
-
)
|
|
76
|
-
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
77
|
-
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
78
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`)
|
|
79
|
-
await queryRunner.query(
|
|
80
|
-
`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)`,
|
|
81
|
-
)
|
|
82
|
-
await queryRunner.query(
|
|
83
|
-
`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"`,
|
|
84
|
-
)
|
|
85
|
-
await queryRunner.query(`DROP TABLE "BaseContact"`)
|
|
86
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`)
|
|
87
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`)
|
|
88
|
-
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`)
|
|
89
|
-
await queryRunner.query(
|
|
90
|
-
`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)`,
|
|
91
|
-
)
|
|
92
|
-
await queryRunner.query(
|
|
93
|
-
`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"`,
|
|
94
|
-
)
|
|
95
|
-
await queryRunner.query(`DROP TABLE "PartyRelationship"`)
|
|
96
|
-
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`)
|
|
97
|
-
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
|
|
98
|
-
await queryRunner.query(
|
|
99
|
-
`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)`,
|
|
100
|
-
)
|
|
101
|
-
await queryRunner.query(
|
|
102
|
-
`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)`,
|
|
103
|
-
)
|
|
104
|
-
await queryRunner.query(
|
|
105
|
-
`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)`,
|
|
106
|
-
)
|
|
107
|
-
await queryRunner.query(
|
|
108
|
-
`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"`,
|
|
109
|
-
)
|
|
110
|
-
await queryRunner.query(`DROP TABLE "Party"`)
|
|
111
|
-
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`)
|
|
112
|
-
await queryRunner.query(
|
|
113
|
-
`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)`,
|
|
114
|
-
)
|
|
115
|
-
await queryRunner.query(
|
|
116
|
-
`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"`,
|
|
117
|
-
)
|
|
118
|
-
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
119
|
-
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
120
|
-
await queryRunner.query(
|
|
121
|
-
`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)`,
|
|
122
|
-
)
|
|
123
|
-
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`)
|
|
124
|
-
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
125
|
-
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
126
|
-
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`)
|
|
127
|
-
await queryRunner.query(
|
|
128
|
-
`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)`,
|
|
129
|
-
)
|
|
130
|
-
await queryRunner.query(
|
|
131
|
-
`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"`,
|
|
132
|
-
)
|
|
133
|
-
await queryRunner.query(`DROP TABLE "BaseConfig"`)
|
|
134
|
-
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`)
|
|
135
|
-
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`)
|
|
136
|
-
|
|
137
|
-
// migrate existing data
|
|
138
|
-
await queryRunner.query(
|
|
139
|
-
`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"`,
|
|
140
|
-
)
|
|
141
|
-
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`)
|
|
142
|
-
await queryRunner.query(
|
|
143
|
-
`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'))`,
|
|
144
|
-
)
|
|
145
|
-
await queryRunner.query(
|
|
146
|
-
`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'))`,
|
|
147
|
-
)
|
|
148
|
-
await queryRunner.query(
|
|
149
|
-
`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"`,
|
|
150
|
-
)
|
|
151
|
-
await queryRunner.query(
|
|
152
|
-
`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"`,
|
|
153
|
-
)
|
|
154
|
-
await queryRunner.query(`DROP TABLE "Contact"`)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
158
|
-
// TODO DPP-27 implement downgrade
|
|
159
|
-
return Promise.reject(Error(`Downgrade is not yet implemented for ${this.name}`))
|
|
160
|
-
}
|
|
161
|
-
}
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateContacts1690925872693 implements MigrationInterface {
|
|
4
|
+
name = 'CreateContacts1690925872693'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`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"))`,
|
|
9
|
+
)
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`,
|
|
12
|
+
)
|
|
13
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
15
|
+
await queryRunner.query(
|
|
16
|
+
`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"))`,
|
|
17
|
+
)
|
|
18
|
+
await queryRunner.query(
|
|
19
|
+
`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"`,
|
|
20
|
+
)
|
|
21
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
22
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
23
|
+
await queryRunner.query(
|
|
24
|
+
`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"))`,
|
|
25
|
+
)
|
|
26
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
27
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
28
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
29
|
+
await queryRunner.query(
|
|
30
|
+
`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"))`,
|
|
31
|
+
)
|
|
32
|
+
await queryRunner.query(
|
|
33
|
+
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`,
|
|
34
|
+
)
|
|
35
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
36
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`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"))`,
|
|
39
|
+
)
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`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"`,
|
|
42
|
+
)
|
|
43
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
44
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
45
|
+
await queryRunner.query(
|
|
46
|
+
`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"))`,
|
|
47
|
+
)
|
|
48
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
49
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
50
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
51
|
+
await queryRunner.query(
|
|
52
|
+
`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 DEFAULT 'EXTERNAL', "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"))`,
|
|
53
|
+
)
|
|
54
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`)
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`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"))`,
|
|
57
|
+
)
|
|
58
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`)
|
|
59
|
+
await queryRunner.query(
|
|
60
|
+
`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')))`,
|
|
61
|
+
)
|
|
62
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
|
|
63
|
+
await queryRunner.query(
|
|
64
|
+
`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)`,
|
|
65
|
+
)
|
|
66
|
+
await queryRunner.query(
|
|
67
|
+
`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"))`,
|
|
68
|
+
)
|
|
69
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`)
|
|
70
|
+
await queryRunner.query(
|
|
71
|
+
`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)`,
|
|
72
|
+
)
|
|
73
|
+
await queryRunner.query(
|
|
74
|
+
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identity_id") SELECT "id", "type", "correlation_id", "identity_id" FROM "CorrelationIdentifier"`,
|
|
75
|
+
)
|
|
76
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
77
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
78
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`)
|
|
79
|
+
await queryRunner.query(
|
|
80
|
+
`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)`,
|
|
81
|
+
)
|
|
82
|
+
await queryRunner.query(
|
|
83
|
+
`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"`,
|
|
84
|
+
)
|
|
85
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`)
|
|
86
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseContact" RENAME TO "BaseContact"`)
|
|
87
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseContact_type" ON "BaseContact" ("type")`)
|
|
88
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`)
|
|
89
|
+
await queryRunner.query(
|
|
90
|
+
`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)`,
|
|
91
|
+
)
|
|
92
|
+
await queryRunner.query(
|
|
93
|
+
`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"`,
|
|
94
|
+
)
|
|
95
|
+
await queryRunner.query(`DROP TABLE "PartyRelationship"`)
|
|
96
|
+
await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`)
|
|
97
|
+
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
|
|
98
|
+
await queryRunner.query(
|
|
99
|
+
`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)`,
|
|
100
|
+
)
|
|
101
|
+
await queryRunner.query(
|
|
102
|
+
`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)`,
|
|
103
|
+
)
|
|
104
|
+
await queryRunner.query(
|
|
105
|
+
`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)`,
|
|
106
|
+
)
|
|
107
|
+
await queryRunner.query(
|
|
108
|
+
`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"`,
|
|
109
|
+
)
|
|
110
|
+
await queryRunner.query(`DROP TABLE "Party"`)
|
|
111
|
+
await queryRunner.query(`ALTER TABLE "temporary_Party" RENAME TO "Party"`)
|
|
112
|
+
await queryRunner.query(
|
|
113
|
+
`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)`,
|
|
114
|
+
)
|
|
115
|
+
await queryRunner.query(
|
|
116
|
+
`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"`,
|
|
117
|
+
)
|
|
118
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
119
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
120
|
+
await queryRunner.query(
|
|
121
|
+
`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)`,
|
|
122
|
+
)
|
|
123
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identity_id") SELECT "id", "type", "identity_id" FROM "Connection"`)
|
|
124
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
125
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
126
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`)
|
|
127
|
+
await queryRunner.query(
|
|
128
|
+
`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)`,
|
|
129
|
+
)
|
|
130
|
+
await queryRunner.query(
|
|
131
|
+
`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"`,
|
|
132
|
+
)
|
|
133
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`)
|
|
134
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseConfig" RENAME TO "BaseConfig"`)
|
|
135
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`)
|
|
136
|
+
|
|
137
|
+
// migrate existing data
|
|
138
|
+
await queryRunner.query(
|
|
139
|
+
`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"`,
|
|
140
|
+
)
|
|
141
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`)
|
|
142
|
+
await queryRunner.query(
|
|
143
|
+
`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'))`,
|
|
144
|
+
)
|
|
145
|
+
await queryRunner.query(
|
|
146
|
+
`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'))`,
|
|
147
|
+
)
|
|
148
|
+
await queryRunner.query(
|
|
149
|
+
`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"`,
|
|
150
|
+
)
|
|
151
|
+
await queryRunner.query(
|
|
152
|
+
`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"`,
|
|
153
|
+
)
|
|
154
|
+
await queryRunner.query(`DROP TABLE "Contact"`)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
158
|
+
// TODO DPP-27 implement downgrade
|
|
159
|
+
return Promise.reject(Error(`Downgrade is not yet implemented for ${this.name}`))
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateStatusList1693866470002 implements MigrationInterface {
|
|
4
|
-
name = 'CreateStatusList1693866470002'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
await queryRunner.query(
|
|
8
|
-
`CREATE TABLE "StatusListEntry" ("statusListId" varchar NOT NULL, "statusListIndex" integer NOT NULL, "credentialId" varchar, "credentialHash" varchar(128), "correlationId" varchar(255), "value" varchar(50), PRIMARY KEY ("statusListId", "statusListIndex"))`,
|
|
9
|
-
)
|
|
10
|
-
await queryRunner.query(
|
|
11
|
-
`CREATE TABLE "StatusList" ("id" varchar PRIMARY KEY NOT NULL, "correlationId" varchar NOT NULL, "length" integer NOT NULL, "issuer" text NOT NULL, "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'), "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'), "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'), "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'), "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'), "statusPurpose" varchar NOT NULL DEFAULT ('revocation'), "statusListCredential" text, CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"))`,
|
|
12
|
-
)
|
|
13
|
-
await queryRunner.query(
|
|
14
|
-
`CREATE TABLE "temporary_StatusListEntry" ("statusListId" varchar NOT NULL, "statusListIndex" integer NOT NULL, "credentialId" varchar, "credentialHash" varchar(128), "correlationId" varchar(255), "value" varchar(50), CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, PRIMARY KEY ("statusListId", "statusListIndex"))`,
|
|
15
|
-
)
|
|
16
|
-
await queryRunner.query(
|
|
17
|
-
`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value") SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value" FROM "StatusListEntry"`,
|
|
18
|
-
)
|
|
19
|
-
await queryRunner.query(`DROP TABLE "StatusListEntry"`)
|
|
20
|
-
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public async down(queryRunner: QueryRunner): Promise<void> {}
|
|
24
|
-
}
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateStatusList1693866470002 implements MigrationInterface {
|
|
4
|
+
name = 'CreateStatusList1693866470002'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "StatusListEntry" ("statusListId" varchar NOT NULL, "statusListIndex" integer NOT NULL, "credentialId" varchar, "credentialHash" varchar(128), "correlationId" varchar(255), "value" varchar(50), PRIMARY KEY ("statusListId", "statusListIndex"))`,
|
|
9
|
+
)
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE TABLE "StatusList" ("id" varchar PRIMARY KEY NOT NULL, "correlationId" varchar NOT NULL, "length" integer NOT NULL, "issuer" text NOT NULL, "type" varchar CHECK( "type" IN ('StatusList2021') ) NOT NULL DEFAULT ('StatusList2021'), "driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'), "credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'), "proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'), "indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ) NOT NULL DEFAULT ('rightToLeft'), "statusPurpose" varchar NOT NULL DEFAULT ('revocation'), "statusListCredential" text, CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId"))`,
|
|
12
|
+
)
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE TABLE "temporary_StatusListEntry" ("statusListId" varchar NOT NULL, "statusListIndex" integer NOT NULL, "credentialId" varchar, "credentialHash" varchar(128), "correlationId" varchar(255), "value" varchar(50), CONSTRAINT "FK_statusListEntry_statusListId" FOREIGN KEY ("statusListId") REFERENCES "StatusList" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, PRIMARY KEY ("statusListId", "statusListIndex"))`,
|
|
15
|
+
)
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`INSERT INTO "temporary_StatusListEntry"("statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value") SELECT "statusListId", "statusListIndex", "credentialId", "credentialHash", "correlationId", "value" FROM "StatusListEntry"`,
|
|
18
|
+
)
|
|
19
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`)
|
|
20
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async down(queryRunner: QueryRunner): Promise<void> {}
|
|
24
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateAuditEvents1701634819487 implements MigrationInterface {
|
|
4
|
-
name = 'CreateAuditEvents1701634819487'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
await queryRunner.query(
|
|
8
|
-
`CREATE TABLE "AuditEvents" ("id" varchar PRIMARY KEY NOT NULL, "timestamp" datetime NOT NULL, "level" varchar CHECK( "level" IN ('0','1','2','3') ) NOT NULL, "correlationId" varchar NOT NULL, "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','credentials','web3','profile','contact') ) NOT NULL, "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') ) NOT NULL, "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL, "actionSubType" varchar NOT NULL, "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL, "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','email','hostname','phone','user') ), "systemCorrelationId" varchar, "systemAlias" varchar, "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','email','hostname','phone') ), "partyCorrelationId" varchar, "partyAlias" varchar, "description" varchar NOT NULL, "data" varchar, "diagnosticData" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
-
await queryRunner.query(`DROP TABLE "AuditEvents"`)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateAuditEvents1701634819487 implements MigrationInterface {
|
|
4
|
+
name = 'CreateAuditEvents1701634819487'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "AuditEvents" ("id" varchar PRIMARY KEY NOT NULL, "timestamp" datetime NOT NULL, "level" varchar CHECK( "level" IN ('0','1','2','3') ) NOT NULL, "correlationId" varchar NOT NULL, "system" varchar CHECK( "system" IN ('general','kms','identity','oid4vci','credentials','web3','profile','contact') ) NOT NULL, "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') ) NOT NULL, "actionType" varchar CHECK( "actionType" IN ('create','read','update','delete','execute') ) NOT NULL, "actionSubType" varchar NOT NULL, "initiatorType" varchar CHECK( "initiatorType" IN ('user','system','external') ) NOT NULL, "systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','email','hostname','phone','user') ), "systemCorrelationId" varchar, "systemAlias" varchar, "partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','email','hostname','phone') ), "partyCorrelationId" varchar, "partyAlias" varchar, "description" varchar NOT NULL, "data" varchar, "diagnosticData" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(`DROP TABLE "AuditEvents"`)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateDigitalCredential1708525189002 implements MigrationInterface {
|
|
4
|
-
name = 'CreateDigitalCredential1708525189002'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
await queryRunner.query(`
|
|
8
|
-
CREATE TABLE "DigitalCredential" (
|
|
9
|
-
"id" varchar PRIMARY KEY NOT NULL,
|
|
10
|
-
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11
|
-
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MDOC') ) NOT NULL,
|
|
12
|
-
"raw_document" text NOT NULL,
|
|
13
|
-
"uniform_document" text NOT NULL,
|
|
14
|
-
"hash" text NOT NULL UNIQUE,
|
|
15
|
-
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID') ) NOT NULL,
|
|
16
|
-
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID') ),
|
|
17
|
-
"issuer_correlation_id" text NOT NULL,
|
|
18
|
-
"subject_correlation_id" text,
|
|
19
|
-
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
|
|
20
|
-
"tenant_id" text,
|
|
21
|
-
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
22
|
-
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
23
|
-
"valid_from" datetime,
|
|
24
|
-
"valid_until" datetime,
|
|
25
|
-
"verified_at" datetime,
|
|
26
|
-
"revoked_at" datetime
|
|
27
|
-
)
|
|
28
|
-
`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
32
|
-
await queryRunner.query(`DROP TABLE "DigitalCredential"`)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateDigitalCredential1708525189002 implements MigrationInterface {
|
|
4
|
+
name = 'CreateDigitalCredential1708525189002'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "DigitalCredential" (
|
|
9
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
10
|
+
"document_type" varchar CHECK( "document_type" IN ('VC', 'VP', 'C', 'P') ) NOT NULL,
|
|
11
|
+
"document_format" varchar CHECK( "document_format" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MDOC') ) NOT NULL,
|
|
12
|
+
"raw_document" text NOT NULL,
|
|
13
|
+
"uniform_document" text NOT NULL,
|
|
14
|
+
"hash" text NOT NULL UNIQUE,
|
|
15
|
+
"issuer_correlation_type" varchar CHECK( "issuer_correlation_type" IN ('DID') ) NOT NULL,
|
|
16
|
+
"subject_correlation_type" varchar CHECK( "subject_correlation_type" IN ('DID') ),
|
|
17
|
+
"issuer_correlation_id" text NOT NULL,
|
|
18
|
+
"subject_correlation_id" text,
|
|
19
|
+
"verified_state" varchar CHECK( "verified_state" IN ('REVOKED', 'VERIFIED', 'EXPIRED') ),
|
|
20
|
+
"tenant_id" text,
|
|
21
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
22
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
23
|
+
"valid_from" datetime,
|
|
24
|
+
"valid_until" datetime,
|
|
25
|
+
"verified_at" datetime,
|
|
26
|
+
"revoked_at" datetime
|
|
27
|
+
)
|
|
28
|
+
`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
32
|
+
await queryRunner.query(`DROP TABLE "DigitalCredential"`)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateMachineStateStore1708796002272 implements MigrationInterface {
|
|
4
|
-
name = 'CreateMachineStateStore1708796002272'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
await queryRunner.query(`
|
|
8
|
-
CREATE TABLE "MachineStateInfoEntity" (
|
|
9
|
-
"instance_id" varchar PRIMARY KEY NOT NULL,
|
|
10
|
-
"session_id" varchar,
|
|
11
|
-
"machine_name" varchar NOT NULL,
|
|
12
|
-
"latest_state_name" varchar,
|
|
13
|
-
"latest_event_type" varchar NOT NULL,
|
|
14
|
-
"state" text NOT NULL,
|
|
15
|
-
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
16
|
-
"updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
17
|
-
"updated_count" integer NOT NULL DEFAULT 0,
|
|
18
|
-
"expires_at" datetime,
|
|
19
|
-
"completed_at" datetime,
|
|
20
|
-
"tenant_id" varchar
|
|
21
|
-
)
|
|
22
|
-
`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
26
|
-
await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateMachineStateStore1708796002272 implements MigrationInterface {
|
|
4
|
+
name = 'CreateMachineStateStore1708796002272'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "MachineStateInfoEntity" (
|
|
9
|
+
"instance_id" varchar PRIMARY KEY NOT NULL,
|
|
10
|
+
"session_id" varchar,
|
|
11
|
+
"machine_name" varchar NOT NULL,
|
|
12
|
+
"latest_state_name" varchar,
|
|
13
|
+
"latest_event_type" varchar NOT NULL,
|
|
14
|
+
"state" text NOT NULL,
|
|
15
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
16
|
+
"updated_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
17
|
+
"updated_count" integer NOT NULL DEFAULT 0,
|
|
18
|
+
"expires_at" datetime,
|
|
19
|
+
"completed_at" datetime,
|
|
20
|
+
"tenant_id" varchar
|
|
21
|
+
)
|
|
22
|
+
`)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
26
|
+
await queryRunner.query(`DROP TABLE "MachineStateInfoEntity"`)
|
|
27
|
+
}
|
|
28
|
+
}
|