Skip to content

Commit 130f6e8

Browse files
authored
Merge pull request #82 from wwWallet/db-migration
Database schema migration
2 parents bea2081 + 7905c43 commit 130f6e8

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/AppDataSource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const AppDataSource: DataSource = new DataSource({
1111
password: config.db.password,
1212
database: config.db.dbname,
1313
entities: [__dirname + "/entities/*.entity.{js,ts}"],
14-
synchronize: true
14+
synchronize: false,
15+
migrations: ["src/migration/**/*.{ts}"],
1516
});
1617

1718
(async function initDataSource() {

src/entities/VerifiableCredential.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class VerifiableCredentialEntity {
1717
@Column({ nullable: false })
1818
credentialIdentifier: string = "";
1919

20-
@Column({ nullable: false, type: 'blob' })
20+
@Column({ nullable: false, type: 'mediumblob' })
2121
credential: string;
2222

2323
@Column({ type: "varchar", nullable: false })
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class IncreaseRawCredentialColumnSize1743779759924 implements MigrationInterface {
4+
name = 'IncreaseRawCredentialColumnSize1743779759924'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`
8+
ALTER TABLE verifiable_credential
9+
MODIFY COLUMN credential MEDIUMBLOB;
10+
`);
11+
}
12+
13+
public async down(queryRunner: QueryRunner): Promise<void> {
14+
await queryRunner.query(`
15+
ALTER TABLE verifiable_credential
16+
MODIFY COLUMN credential BLOB;
17+
`);
18+
}
19+
20+
}

0 commit comments

Comments
 (0)