@sphereon/ssi-sdk.data-store 0.24.0 → 0.24.1-next.100
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 +1 -1
- package/dist/contact/ContactStore.d.ts +3 -0
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +84 -48
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/entities/contact/BaseContactEntity.d.ts +2 -0
- package/dist/entities/contact/BaseContactEntity.d.ts.map +1 -1
- package/dist/entities/contact/BaseContactEntity.js +12 -3
- package/dist/entities/contact/BaseContactEntity.js.map +1 -1
- package/dist/entities/contact/ConnectionEntity.d.ts +2 -0
- package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
- package/dist/entities/contact/ConnectionEntity.js +8 -0
- package/dist/entities/contact/ConnectionEntity.js.map +1 -1
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts +14 -0
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts.map +1 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js +88 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.js +8 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +2 -0
- package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.js +8 -0
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +2 -0
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +8 -0
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IMetadataEntity.d.ts +8 -0
- package/dist/entities/contact/IMetadataEntity.d.ts.map +1 -0
- package/dist/entities/contact/IMetadataEntity.js +2 -0
- package/dist/entities/contact/IMetadataEntity.js.map +1 -0
- package/dist/entities/contact/IdentityEntity.d.ts +5 -2
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +13 -0
- package/dist/entities/contact/IdentityEntity.js.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +6 -2
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.js +19 -3
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.d.ts +2 -0
- package/dist/entities/contact/NaturalPersonEntity.d.ts.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.js +8 -0
- package/dist/entities/contact/NaturalPersonEntity.js.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +2 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.js +8 -0
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
- package/dist/entities/contact/OrganizationEntity.d.ts +2 -0
- package/dist/entities/contact/OrganizationEntity.d.ts.map +1 -1
- package/dist/entities/contact/OrganizationEntity.js +8 -0
- package/dist/entities/contact/OrganizationEntity.js.map +1 -1
- package/dist/entities/contact/PartyEntity.d.ts +2 -0
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +8 -0
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +2 -0
- package/dist/entities/contact/PartyRelationshipEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.js +8 -0
- package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -1
- package/dist/entities/contact/PartyTypeEntity.js +4 -4
- package/dist/entities/contact/PartyTypeEntity.js.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.d.ts +2 -0
- package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.js +10 -1
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -1
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts +14 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts.map +1 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js +74 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js +78 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.js +78 -0
- package/dist/migrations/generic/8-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.js +78 -0
- package/dist/migrations/generic/9-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +2 -0
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +12 -2
- 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 +2 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +40 -3
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js +63 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +74 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +41 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +40 -3
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +79 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +73 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +38 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts +12 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.js +7 -0
- package/dist/presentationDefinition/AbstractPDStore.js.map +1 -0
- package/dist/presentationDefinition/PDStore.d.ts +19 -0
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/PDStore.js +152 -0
- package/dist/presentationDefinition/PDStore.js.map +1 -0
- package/dist/types/contact/contact.d.ts +51 -15
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +12 -7
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts +17 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts.map +1 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js +3 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts +16 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.js +3 -0
- package/dist/types/presentationDefinition/presentationDefinition.js.map +1 -0
- package/dist/utils/contact/MappingUtils.d.ts +6 -4
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +128 -18
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.d.ts +6 -0
- package/dist/utils/presentationDefinition/MappingUtils.d.ts.map +1 -0
- package/dist/utils/presentationDefinition/MappingUtils.js +48 -0
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -0
- package/package.json +7 -4
- package/src/__tests__/contact.entities.test.ts +129 -44
- package/src/__tests__/contact.store.test.ts +205 -29
- package/src/__tests__/pd-manager.entities.test.ts +71 -0
- package/src/__tests__/pd-manager.store.test.ts +191 -0
- package/src/contact/ContactStore.ts +74 -30
- package/src/entities/contact/BaseContactEntity.ts +11 -0
- package/src/entities/contact/ConnectionEntity.ts +6 -0
- package/src/entities/contact/ContactMetadataItemEntity.ts +50 -0
- package/src/entities/contact/CorrelationIdentifierEntity.ts +6 -0
- package/src/entities/contact/DidAuthConfigEntity.ts +6 -0
- package/src/entities/contact/ElectronicAddressEntity.ts +6 -0
- package/src/entities/contact/IMetadataEntity.ts +7 -0
- package/src/entities/contact/IdentityEntity.ts +11 -2
- package/src/entities/contact/IdentityMetadataItemEntity.ts +16 -4
- package/src/entities/contact/NaturalPersonEntity.ts +6 -0
- package/src/entities/contact/OpenIdConfigEntity.ts +6 -0
- package/src/entities/contact/OrganizationEntity.ts +6 -0
- package/src/entities/contact/PartyEntity.ts +6 -0
- package/src/entities/contact/PartyRelationshipEntity.ts +6 -0
- package/src/entities/contact/PartyTypeEntity.ts +4 -4
- package/src/entities/contact/PhysicalAddressEntity.ts +9 -2
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +43 -0
- package/src/index.ts +13 -0
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -0
- package/src/migrations/generic/8-CreateContacts.ts +66 -0
- package/src/migrations/generic/9-CreateContacts.ts +66 -0
- package/src/migrations/generic/index.ts +11 -1
- package/src/migrations/index.ts +1 -0
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +59 -5
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -0
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -0
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +70 -3
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -0
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -0
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -0
- package/src/presentationDefinition/AbstractPDStore.ts +20 -0
- package/src/presentationDefinition/PDStore.ts +185 -0
- package/src/types/contact/contact.ts +56 -15
- package/src/types/index.ts +2 -0
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -0
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -0
- package/src/utils/contact/MappingUtils.ts +135 -19
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
1
|
+
import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
|
|
2
2
|
import {
|
|
3
3
|
BaseEntity,
|
|
4
4
|
BeforeInsert,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
14
14
|
import { PhysicalAddressType, ValidationConstraint } from '../../types'
|
|
15
15
|
import { PartyEntity } from './PartyEntity'
|
|
16
|
+
import { IsNonEmptyStringConstraint } from '../validators'
|
|
16
17
|
|
|
17
18
|
@Entity('PhysicalAddress')
|
|
18
19
|
export class PhysicalAddressEntity extends BaseEntity {
|
|
@@ -48,9 +49,15 @@ export class PhysicalAddressEntity extends BaseEntity {
|
|
|
48
49
|
countryCode!: string
|
|
49
50
|
|
|
50
51
|
@Column({ name: 'building_name', length: 255, nullable: true })
|
|
51
|
-
@
|
|
52
|
+
@Validate(IsNonEmptyStringConstraint, { message: 'Blank building names are not allowed' })
|
|
52
53
|
buildingName?: string
|
|
53
54
|
|
|
55
|
+
@Column({name: 'owner_id', nullable: true})
|
|
56
|
+
ownerId?: string
|
|
57
|
+
|
|
58
|
+
@Column({name: 'tenant_id', nullable: true})
|
|
59
|
+
tenantId?: string
|
|
60
|
+
|
|
54
61
|
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.physicalAddresses, {
|
|
55
62
|
onDelete: 'CASCADE',
|
|
56
63
|
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
+
import { IsNotEmpty } from 'class-validator'
|
|
3
|
+
|
|
4
|
+
@Entity('PresentationDefinitionItem')
|
|
5
|
+
@Index(['version'], { unique: false })
|
|
6
|
+
export class PresentationDefinitionItemEntity extends BaseEntity {
|
|
7
|
+
@PrimaryGeneratedColumn('uuid')
|
|
8
|
+
id!: string
|
|
9
|
+
|
|
10
|
+
@Column({ name: 'definition_id', length: 255, nullable: false, unique: false })
|
|
11
|
+
@IsNotEmpty({ message: 'A blank definition id field is not allowed' })
|
|
12
|
+
definitionId!: string
|
|
13
|
+
|
|
14
|
+
@Column({ name: 'version', length: 255, nullable: false, unique: false })
|
|
15
|
+
@IsNotEmpty({ message: 'A blank version field is not allowed' })
|
|
16
|
+
version!: string
|
|
17
|
+
|
|
18
|
+
@Column({ name: 'tenant_id', length: 255, nullable: true, unique: false })
|
|
19
|
+
tenantId?: string
|
|
20
|
+
|
|
21
|
+
@Column({ name: 'purpose', length: 255, nullable: true, unique: false })
|
|
22
|
+
purpose?: string
|
|
23
|
+
|
|
24
|
+
@Column({ name: 'name', length: 255, nullable: true, unique: false })
|
|
25
|
+
name?: string
|
|
26
|
+
|
|
27
|
+
@Column({ name: 'definition_payload', type: 'text', nullable: false, unique: false })
|
|
28
|
+
@IsNotEmpty({ message: 'A blank definition payload field is not allowed' })
|
|
29
|
+
definitionPayload!: string
|
|
30
|
+
|
|
31
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
32
|
+
createdAt!: Date
|
|
33
|
+
|
|
34
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
35
|
+
lastUpdatedAt!: Date
|
|
36
|
+
|
|
37
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
38
|
+
@BeforeInsert()
|
|
39
|
+
@BeforeUpdate()
|
|
40
|
+
updateUpdatedDate(): void {
|
|
41
|
+
this.lastUpdatedAt = new Date()
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -34,10 +34,15 @@ export { StatusListStore } from './statusList/StatusListStore'
|
|
|
34
34
|
import { AuditEventEntity, auditEventEntityFrom } from './entities/eventLogger/AuditEventEntity'
|
|
35
35
|
import { DigitalCredentialEntity } from './entities/digitalCredential/DigitalCredentialEntity'
|
|
36
36
|
import { digitalCredentialFrom, digitalCredentialsFrom, nonPersistedDigitalCredentialEntityFromAddArgs } from './utils/digitalCredential/MappingUtils'
|
|
37
|
+
import { isPresentationDefinitionEqual } from './utils/presentationDefinition/MappingUtils'
|
|
38
|
+
import { PresentationDefinitionItemEntity } from './entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
39
|
+
import { ContactMetadataItemEntity } from './entities/contact/ContactMetadataItemEntity'
|
|
37
40
|
export { AbstractEventLoggerStore } from './eventLogger/AbstractEventLoggerStore'
|
|
38
41
|
export { EventLoggerStore } from './eventLogger/EventLoggerStore'
|
|
39
42
|
export { IAbstractMachineStateStore } from './machineState/IAbstractMachineStateStore'
|
|
40
43
|
export { MachineStateStore } from './machineState/MachineStateStore'
|
|
44
|
+
export { AbstractPDStore } from './presentationDefinition/AbstractPDStore'
|
|
45
|
+
export { PDStore } from './presentationDefinition/PDStore'
|
|
41
46
|
|
|
42
47
|
export {
|
|
43
48
|
DataStoreMigrations,
|
|
@@ -46,6 +51,7 @@ export {
|
|
|
46
51
|
DataStoreIssuanceBrandingMigrations,
|
|
47
52
|
DataStoreStatusListMigrations,
|
|
48
53
|
DataStoreMachineStateMigrations,
|
|
54
|
+
DataStorePresentationDefinitionMigrations,
|
|
49
55
|
} from './migrations'
|
|
50
56
|
export * from './types'
|
|
51
57
|
export * from './utils/contact/MappingUtils'
|
|
@@ -66,6 +72,7 @@ export const DataStoreContactEntities = [
|
|
|
66
72
|
NaturalPersonEntity,
|
|
67
73
|
ElectronicAddressEntity,
|
|
68
74
|
PhysicalAddressEntity,
|
|
75
|
+
ContactMetadataItemEntity,
|
|
69
76
|
]
|
|
70
77
|
|
|
71
78
|
export const DataStoreIssuanceBrandingEntities = [
|
|
@@ -80,6 +87,8 @@ export const DataStoreIssuanceBrandingEntities = [
|
|
|
80
87
|
IssuerLocaleBrandingEntity,
|
|
81
88
|
]
|
|
82
89
|
|
|
90
|
+
export const DataStorePresentationDefinitionEntities = [PresentationDefinitionItemEntity]
|
|
91
|
+
|
|
83
92
|
export const DataStoreStatusListEntities = [StatusListEntity, StatusListEntryEntity]
|
|
84
93
|
|
|
85
94
|
export const DataStoreEventLoggerEntities = [AuditEventEntity]
|
|
@@ -96,6 +105,7 @@ export const DataStoreEntities = [
|
|
|
96
105
|
...DataStoreEventLoggerEntities,
|
|
97
106
|
...DataStoreDigitalCredentialEntities,
|
|
98
107
|
...DataStoreMachineStateEntities,
|
|
108
|
+
...DataStorePresentationDefinitionEntities,
|
|
99
109
|
]
|
|
100
110
|
|
|
101
111
|
export {
|
|
@@ -138,4 +148,7 @@ export {
|
|
|
138
148
|
digitalCredentialsFrom,
|
|
139
149
|
nonPersistedDigitalCredentialEntityFromAddArgs,
|
|
140
150
|
MachineStateInfoEntity,
|
|
151
|
+
PresentationDefinitionItemEntity,
|
|
152
|
+
isPresentationDefinitionEqual,
|
|
153
|
+
ContactMetadataItemEntity,
|
|
141
154
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
import Debug from 'debug'
|
|
3
|
+
import { CreatePresentationDefinitions1716475165345 } from '../postgres/1716475165345-CreatePresentationDefinitions'
|
|
4
|
+
import { CreatePresentationDefinitions1716475165344 } from '../sqlite/1716475165344-CreatePresentationDefinitions'
|
|
5
|
+
|
|
6
|
+
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
|
+
|
|
8
|
+
export class CreatePresentationDefinitions1716533767523 implements MigrationInterface {
|
|
9
|
+
name = 'CreatePresentationDefinitionItems1716533767523'
|
|
10
|
+
|
|
11
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
debug('migration: creating machine state tables')
|
|
13
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
14
|
+
|
|
15
|
+
switch (dbType) {
|
|
16
|
+
case 'postgres': {
|
|
17
|
+
debug('using postgres migration file')
|
|
18
|
+
const mig: CreatePresentationDefinitions1716475165345 = new CreatePresentationDefinitions1716475165345()
|
|
19
|
+
await mig.up(queryRunner)
|
|
20
|
+
debug('Migration statements executed')
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
case 'sqlite':
|
|
24
|
+
case 'expo':
|
|
25
|
+
case 'react-native': {
|
|
26
|
+
debug('using sqlite/react-native migration file')
|
|
27
|
+
const mig: CreatePresentationDefinitions1716475165344 = new CreatePresentationDefinitions1716475165344()
|
|
28
|
+
await mig.up(queryRunner)
|
|
29
|
+
debug('Migration statements executed')
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
return Promise.reject(
|
|
34
|
+
`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`,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
40
|
+
debug('migration: reverting machine state tables')
|
|
41
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
42
|
+
|
|
43
|
+
switch (dbType) {
|
|
44
|
+
case 'postgres': {
|
|
45
|
+
debug('using postgres migration file')
|
|
46
|
+
const mig: CreatePresentationDefinitions1716475165345 = new CreatePresentationDefinitions1716475165345()
|
|
47
|
+
await mig.down(queryRunner)
|
|
48
|
+
debug('Migration statements executed')
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
case 'sqlite':
|
|
52
|
+
case 'expo':
|
|
53
|
+
case 'react-native': {
|
|
54
|
+
debug('using sqlite/react-native migration file')
|
|
55
|
+
const mig: CreatePresentationDefinitions1716475165344 = new CreatePresentationDefinitions1716475165344()
|
|
56
|
+
await mig.down(queryRunner)
|
|
57
|
+
debug('Migration statements executed')
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return Promise.reject(
|
|
62
|
+
`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`,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
import Debug from 'debug'
|
|
3
|
+
import {CreateContacts1710438363001} from "../postgres/1710438363001-CreateContacts";
|
|
4
|
+
import {CreateContacts1710438363002} from "../sqlite/1710438363002-CreateContacts";
|
|
5
|
+
|
|
6
|
+
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
|
+
|
|
8
|
+
export class CreateContacts1708525189000 implements MigrationInterface {
|
|
9
|
+
name = 'CreateContacts1708525189000'
|
|
10
|
+
|
|
11
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
debug('migration: updating contact tables')
|
|
13
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
14
|
+
|
|
15
|
+
switch (dbType) {
|
|
16
|
+
case 'postgres': {
|
|
17
|
+
debug('using postgres migration file')
|
|
18
|
+
const mig: CreateContacts1710438363001 = new CreateContacts1710438363001()
|
|
19
|
+
await mig.up(queryRunner)
|
|
20
|
+
debug('Migration statements executed')
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
case 'sqlite':
|
|
24
|
+
case 'expo':
|
|
25
|
+
case 'react-native': {
|
|
26
|
+
debug('using sqlite/react-native migration file')
|
|
27
|
+
const mig: CreateContacts1710438363002 = new CreateContacts1710438363002()
|
|
28
|
+
await mig.up(queryRunner)
|
|
29
|
+
debug('Migration statements executed')
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
return Promise.reject(
|
|
34
|
+
`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`
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
40
|
+
debug('migration: reverting machine state tables')
|
|
41
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
42
|
+
|
|
43
|
+
switch (dbType) {
|
|
44
|
+
case 'postgres': {
|
|
45
|
+
debug('using postgres migration file')
|
|
46
|
+
const mig: CreateContacts1710438363001 = new CreateContacts1710438363001()
|
|
47
|
+
await mig.down(queryRunner)
|
|
48
|
+
debug('Migration statements executed')
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
case 'sqlite':
|
|
52
|
+
case 'expo':
|
|
53
|
+
case 'react-native': {
|
|
54
|
+
debug('using sqlite/react-native migration file')
|
|
55
|
+
const mig: CreateContacts1710438363002 = new CreateContacts1710438363002()
|
|
56
|
+
await mig.down(queryRunner)
|
|
57
|
+
debug('Migration statements executed')
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return Promise.reject(
|
|
62
|
+
`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`
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
import Debug from 'debug'
|
|
3
|
+
import { CreateContacts1715761125001 } from '../postgres/1715761125001-CreateContacts'
|
|
4
|
+
import { CreateContacts1715761125002 } from '../sqlite/1715761125002-CreateContacts'
|
|
5
|
+
|
|
6
|
+
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
|
+
|
|
8
|
+
export class CreateContacts1715761125000 implements MigrationInterface {
|
|
9
|
+
name = 'CreateContacts1715761125000'
|
|
10
|
+
|
|
11
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
debug('migration: updating contact tables')
|
|
13
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
14
|
+
|
|
15
|
+
switch (dbType) {
|
|
16
|
+
case 'postgres': {
|
|
17
|
+
debug('using postgres migration file')
|
|
18
|
+
const mig: CreateContacts1715761125001 = new CreateContacts1715761125001()
|
|
19
|
+
await mig.up(queryRunner)
|
|
20
|
+
debug('Migration statements executed')
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
case 'sqlite':
|
|
24
|
+
case 'expo':
|
|
25
|
+
case 'react-native': {
|
|
26
|
+
debug('using sqlite/react-native migration file')
|
|
27
|
+
const mig: CreateContacts1715761125002 = new CreateContacts1715761125002()
|
|
28
|
+
await mig.up(queryRunner)
|
|
29
|
+
debug('Migration statements executed')
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
return Promise.reject(
|
|
34
|
+
`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`,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
40
|
+
debug('migration: reverting machine state tables')
|
|
41
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
42
|
+
|
|
43
|
+
switch (dbType) {
|
|
44
|
+
case 'postgres': {
|
|
45
|
+
debug('using postgres migration file')
|
|
46
|
+
const mig: CreateContacts1715761125001 = new CreateContacts1715761125001()
|
|
47
|
+
await mig.down(queryRunner)
|
|
48
|
+
debug('Migration statements executed')
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
case 'sqlite':
|
|
52
|
+
case 'expo':
|
|
53
|
+
case 'react-native': {
|
|
54
|
+
debug('using sqlite/react-native migration file')
|
|
55
|
+
const mig: CreateContacts1715761125002 = new CreateContacts1715761125002()
|
|
56
|
+
await mig.down(queryRunner)
|
|
57
|
+
debug('Migration statements executed')
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return Promise.reject(
|
|
62
|
+
`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`,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -5,6 +5,9 @@ import { CreateStatusList1693866470000 } from './4-CreateStatusList'
|
|
|
5
5
|
import { CreateAuditEvents1701635835330 } from './5-CreateAuditEvents'
|
|
6
6
|
import { CreateDigitalCredential1708525189000 } from './6-CreateDigitalCredential'
|
|
7
7
|
import { CreateMachineStateStore1708098041262 } from './7-CreateMachineStateStore'
|
|
8
|
+
import { CreateContacts1708525189000 } from './8-CreateContacts'
|
|
9
|
+
import { CreateContacts1715761125000 } from './9-CreateContacts'
|
|
10
|
+
import { CreatePresentationDefinitions1716533767523 } from './10-CreatePresentationDefinitions'
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* The migrations array that SHOULD be used when initializing a TypeORM database connection.
|
|
@@ -15,12 +18,18 @@ import { CreateMachineStateStore1708098041262 } from './7-CreateMachineStateStor
|
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
// Individual migrations per purpose. Allows parties to not run migrations and thus create/update tables if they are not using a particular feature (yet)
|
|
18
|
-
export const DataStoreContactMigrations = [
|
|
21
|
+
export const DataStoreContactMigrations = [
|
|
22
|
+
CreateContacts1659463079429,
|
|
23
|
+
CreateContacts1690925872318,
|
|
24
|
+
CreateContacts1708525189000,
|
|
25
|
+
CreateContacts1715761125000,
|
|
26
|
+
]
|
|
19
27
|
export const DataStoreIssuanceBrandingMigrations = [CreateIssuanceBranding1659463079429]
|
|
20
28
|
export const DataStoreStatusListMigrations = [CreateStatusList1693866470000]
|
|
21
29
|
export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
|
|
22
30
|
export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000]
|
|
23
31
|
export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
|
|
32
|
+
export const DataStorePresentationDefinitionMigrations = [CreatePresentationDefinitions1716533767523]
|
|
24
33
|
|
|
25
34
|
// All migrations together
|
|
26
35
|
export const DataStoreMigrations = [
|
|
@@ -30,4 +39,5 @@ export const DataStoreMigrations = [
|
|
|
30
39
|
...DataStoreEventLoggerMigrations,
|
|
31
40
|
...DataStoreDigitalCredentialMigrations,
|
|
32
41
|
...DataStoreMachineStateMigrations,
|
|
42
|
+
...DataStorePresentationDefinitionMigrations,
|
|
33
43
|
]
|
package/src/migrations/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class CreateContacts1690925872592 implements MigrationInterface {
|
|
|
15
15
|
await queryRunner.query(`CREATE TYPE "public"."PartyType_type_enum" AS ENUM('naturalPerson', 'organization')`)
|
|
16
16
|
await queryRunner.query(`CREATE TYPE "public"."PartyOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`)
|
|
17
17
|
await queryRunner.query(
|
|
18
|
-
`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
|
|
18
|
+
`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"))`,
|
|
19
19
|
)
|
|
20
20
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyType_type_tenant_id" ON "PartyType" ("type", "tenant_id")`)
|
|
21
21
|
await queryRunner.query(
|
|
@@ -30,8 +30,8 @@ export class CreateContacts1690925872592 implements MigrationInterface {
|
|
|
30
30
|
`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"))`,
|
|
31
31
|
)
|
|
32
32
|
await queryRunner.query(
|
|
33
|
-
`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"))
|
|
34
|
-
)
|
|
33
|
+
`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"))`,
|
|
34
|
+
)
|
|
35
35
|
await queryRunner.query(
|
|
36
36
|
`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"))`,
|
|
37
37
|
)
|
|
@@ -41,6 +41,10 @@ export class CreateContacts1690925872592 implements MigrationInterface {
|
|
|
41
41
|
await queryRunner.query(`CREATE INDEX "IDX_BaseConfig_type" ON "BaseConfig" ("type")`)
|
|
42
42
|
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "contactId" TO "partyId"`)
|
|
43
43
|
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" SET NOT NULL`)
|
|
44
|
+
await queryRunner.query(`CREATE TYPE "public"."IdentityOrigin_type_enum" AS ENUM('INTERNAL', 'EXTERNAL')`)
|
|
45
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "origin" "public"."IdentityOrigin_type_enum" DEFAULT 'EXTERNAL' NOT NULL`)
|
|
46
|
+
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "origin" DROP DEFAULT`)
|
|
47
|
+
|
|
44
48
|
await queryRunner.query(
|
|
45
49
|
`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identity_id" FOREIGN KEY ("identity_id") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
46
50
|
)
|
|
@@ -98,7 +102,57 @@ export class CreateContacts1690925872592 implements MigrationInterface {
|
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP CONSTRAINT "FK_BaseConfig_connection_id"`)
|
|
106
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identity_id"`)
|
|
107
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_partyId"`)
|
|
108
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP CONSTRAINT "FK_Party_party_type_id"`)
|
|
109
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP CONSTRAINT "FK_PhysicalAddress_partyId"`)
|
|
110
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP CONSTRAINT "FK_ElectronicAddress_partyId"`)
|
|
111
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_right_id"`)
|
|
112
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP CONSTRAINT "FK_PartyRelationship_left_id"`)
|
|
113
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP CONSTRAINT "FK_BaseContact_party_id"`)
|
|
114
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`)
|
|
115
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identity_id"`)
|
|
116
|
+
|
|
117
|
+
await queryRunner.query(`ALTER TABLE "Identity" ALTER COLUMN "roles" DROP NOT NULL`)
|
|
118
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "origin"`)
|
|
119
|
+
await queryRunner.query(`DROP TYPE "public"."IdentityOrigin_type_enum"`)
|
|
120
|
+
await queryRunner.query(`ALTER TABLE "Identity" RENAME COLUMN "partyId" TO "contactId"`)
|
|
121
|
+
await queryRunner.query(`ALTER TABLE "Connection" RENAME COLUMN "identity_id" TO "identityId"`)
|
|
122
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME COLUMN "identity_id" TO "identityId"`)
|
|
123
|
+
|
|
124
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfig_type"`)
|
|
125
|
+
await queryRunner.query(`DROP TABLE "BaseConfig"`)
|
|
126
|
+
await queryRunner.query(`DROP TABLE "Party"`)
|
|
127
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyRelationship_left_right"`)
|
|
128
|
+
await queryRunner.query(`DROP TABLE "PartyRelationship"`)
|
|
129
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseContact_type"`)
|
|
130
|
+
await queryRunner.query(`DROP TABLE "BaseContact"`)
|
|
131
|
+
await queryRunner.query(`DROP TABLE "ElectronicAddress"`)
|
|
132
|
+
await queryRunner.query(`DROP TABLE "PhysicalAddress"`)
|
|
133
|
+
await queryRunner.query(`DROP INDEX "IDX_PartyType_type_tenant_id"`)
|
|
134
|
+
await queryRunner.query(`DROP TABLE "PartyType"`)
|
|
135
|
+
await queryRunner.query(`DROP TYPE "public"."PartyOrigin_type_enum"`)
|
|
136
|
+
await queryRunner.query(`DROP TYPE "public"."PartyType_type_enum"`)
|
|
137
|
+
|
|
138
|
+
await queryRunner.query(
|
|
139
|
+
`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
140
|
+
)
|
|
141
|
+
await queryRunner.query(
|
|
142
|
+
`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
143
|
+
)
|
|
144
|
+
await queryRunner.query(
|
|
145
|
+
`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
146
|
+
)
|
|
147
|
+
await queryRunner.query(
|
|
148
|
+
`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
await queryRunner.query(
|
|
152
|
+
`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"))`,
|
|
153
|
+
)
|
|
154
|
+
await queryRunner.query(
|
|
155
|
+
`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'`,
|
|
156
|
+
)
|
|
103
157
|
}
|
|
104
158
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateContacts1710438363001 implements MigrationInterface {
|
|
4
|
+
name = 'CreateContacts1710438363001'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "owner_id" uuid`)
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "Party" ADD COLUMN "tenant_id" uuid`)
|
|
9
|
+
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "owner_id" uuid`)
|
|
11
|
+
await queryRunner.query(`ALTER TABLE "Identity" ADD COLUMN "tenant_id" uuid`)
|
|
12
|
+
|
|
13
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "owner_id" uuid`)
|
|
14
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" ADD COLUMN "tenant_id" uuid`)
|
|
15
|
+
|
|
16
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "owner_id" uuid`)
|
|
17
|
+
await queryRunner.query(`ALTER TABLE "Connection" ADD COLUMN "tenant_id" uuid`)
|
|
18
|
+
|
|
19
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "owner_id" uuid`)
|
|
20
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" ADD COLUMN "tenant_id" uuid`)
|
|
21
|
+
|
|
22
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "owner_id" uuid`)
|
|
23
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" ADD COLUMN "tenant_id" uuid`)
|
|
24
|
+
|
|
25
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "owner_id" uuid`)
|
|
26
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" ADD COLUMN "tenant_id" uuid`)
|
|
27
|
+
|
|
28
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "owner_id" uuid`)
|
|
29
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" ADD COLUMN "tenant_id" uuid`)
|
|
30
|
+
|
|
31
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "owner_id" uuid`)
|
|
32
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" ADD COLUMN "tenant_id" uuid`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
36
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "tenant_id"`)
|
|
37
|
+
await queryRunner.query(`ALTER TABLE "PhysicalAddress" DROP COLUMN "owner_id"`)
|
|
38
|
+
|
|
39
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "tenant_id"`)
|
|
40
|
+
await queryRunner.query(`ALTER TABLE "ElectronicAddress" DROP COLUMN "owner_id"`)
|
|
41
|
+
|
|
42
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "tenant_id"`)
|
|
43
|
+
await queryRunner.query(`ALTER TABLE "PartyRelationship" DROP COLUMN "owner_id"`)
|
|
44
|
+
|
|
45
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "tenant_id"`)
|
|
46
|
+
await queryRunner.query(`ALTER TABLE "BaseContact" DROP COLUMN "owner_id"`)
|
|
47
|
+
|
|
48
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "tenant_id"`)
|
|
49
|
+
await queryRunner.query(`ALTER TABLE "BaseConfig" DROP COLUMN "owner_id"`)
|
|
50
|
+
|
|
51
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "tenant_id"`)
|
|
52
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP COLUMN "owner_id"`)
|
|
53
|
+
|
|
54
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "tenant_id"`)
|
|
55
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP COLUMN "owner_id"`)
|
|
56
|
+
|
|
57
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "tenant_id"`)
|
|
58
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP COLUMN "owner_id"`)
|
|
59
|
+
|
|
60
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "tenant_id"`)
|
|
61
|
+
await queryRunner.query(`ALTER TABLE "Party" DROP COLUMN "owner_id"`)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateContacts1715761125001 implements MigrationInterface {
|
|
4
|
+
name = 'CreateContacts1715761125001'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
// Upgrade IdentityMetadata table
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`)
|
|
9
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
10
|
+
(
|
|
11
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
12
|
+
"label" character varying(255) NOT NULL,
|
|
13
|
+
"valueType" character varying NOT NULL,
|
|
14
|
+
"stringValue" text,
|
|
15
|
+
"numberValue" double precision,
|
|
16
|
+
"dateValue" TIMESTAMP,
|
|
17
|
+
"boolValue" boolean,
|
|
18
|
+
"identityId" uuid,
|
|
19
|
+
CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
20
|
+
)`)
|
|
21
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "valueType", "stringValue", "identityId")
|
|
22
|
+
SELECT "id", "label", 'string', "value", "identityId"
|
|
23
|
+
FROM "temporary_IdentityMetadata"`)
|
|
24
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`)
|
|
25
|
+
|
|
26
|
+
// Create new ContactMetadata table
|
|
27
|
+
await queryRunner.query(`CREATE TABLE "ContactMetadata"
|
|
28
|
+
(
|
|
29
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
30
|
+
"label" character varying(255) NOT NULL,
|
|
31
|
+
"valueType" character varying NOT NULL,
|
|
32
|
+
"stringValue" text,
|
|
33
|
+
"numberValue" double precision,
|
|
34
|
+
"dateValue" TIMESTAMP,
|
|
35
|
+
"boolValue" boolean,
|
|
36
|
+
"contactId" uuid,
|
|
37
|
+
CONSTRAINT "FK_BaseContact_ContactMetadata" FOREIGN KEY ("contactId") REFERENCES "BaseContact" ("id") ON DELETE CASCADE
|
|
38
|
+
)`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
42
|
+
// Drop the ContactMetadata table
|
|
43
|
+
await queryRunner.query(`DROP TABLE "ContactMetadata"`)
|
|
44
|
+
|
|
45
|
+
// Restore the IdentityMetadata table
|
|
46
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`)
|
|
47
|
+
await queryRunner.query(`CREATE TABLE "IdentityMetadata"
|
|
48
|
+
(
|
|
49
|
+
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
|
|
50
|
+
"label" character varying(255) NOT NULL,
|
|
51
|
+
"value" character varying(255) NOT NULL,
|
|
52
|
+
"identityId" uuid,
|
|
53
|
+
CONSTRAINT "FK_Identity_IdentityMetadata" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE
|
|
54
|
+
)`)
|
|
55
|
+
await queryRunner.query(`INSERT INTO "IdentityMetadata" ("id", "label", "value", "identityId")
|
|
56
|
+
SELECT "id", "label", "stringValue", "identityId"
|
|
57
|
+
FROM "temporary_IdentityMetadata"`)
|
|
58
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreatePresentationDefinitions1716475165345 implements MigrationInterface {
|
|
4
|
+
name = 'CreatePresentationDefinitions1716475165345'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "PresentationDefinitionItem" (
|
|
9
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
10
|
+
"tenant_id" TEXT,
|
|
11
|
+
"definition_id" TEXT NOT NULL,
|
|
12
|
+
"name" TEXT,
|
|
13
|
+
"version" TEXT NOT NULL,
|
|
14
|
+
"purpose" TEXT,
|
|
15
|
+
"definition_payload" TEXT NOT NULL,
|
|
16
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
17
|
+
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
18
|
+
CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
|
|
19
|
+
`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
23
|
+
await queryRunner.query(`DROP TABLE "PresentationDefinitionItem"`)
|
|
24
|
+
}
|
|
25
|
+
}
|