Skip to content

Commit fab0392

Browse files
authored
fix(api-database): make columns case insensitive (#971)
* create citext extension * make columns case insensitive
1 parent 55dd82c commit fab0392

7 files changed

Lines changed: 22 additions & 21 deletions

File tree

packages/api-database/source/models/block.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Column, Entity, Unique } from "typeorm";
99
export class Block {
1010
@Column({
1111
primary: true,
12-
type: "varchar",
12+
type: "citext",
1313
})
1414
public readonly hash!: string;
1515

@@ -25,12 +25,12 @@ export class Block {
2525
public readonly timestamp!: string;
2626

2727
@Column({
28-
type: "varchar",
28+
type: "citext",
2929
})
3030
public readonly parentHash!: string;
3131

3232
@Column({
33-
type: "varchar",
33+
type: "citext",
3434
})
3535
public readonly stateRoot!: string;
3636

@@ -78,13 +78,13 @@ export class Block {
7878

7979
@Column({
8080
nullable: false,
81-
type: "varchar",
81+
type: "citext",
8282
})
8383
public readonly transactionsRoot!: string;
8484

8585
@Column({
8686
nullable: false,
87-
type: "varchar",
87+
type: "citext",
8888
})
8989
public readonly proposer!: string;
9090

packages/api-database/source/models/contract.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ import { Column, Entity } from "typeorm";
66
export class Contract {
77
@Column({
88
primary: true,
9-
type: "varchar",
9+
type: "citext",
1010
})
1111
public readonly name!: string;
1212

1313
@Column({
1414
nullable: false,
15-
type: "varchar",
15+
type: "citext",
1616
})
1717
public readonly address!: string;
1818

1919
@Column({
2020
default: undefined,
2121
nullable: true,
22-
type: "varchar",
22+
type: "citext",
2323
})
2424
public readonly proxy!: string | undefined;
2525

2626
@Column({
2727
nullable: false,
28-
type: "varchar",
28+
type: "citext",
2929
})
3030
public readonly activeImplementation!: string;
3131

packages/api-database/source/models/legacy-cold-wallet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Column, Entity } from "typeorm";
66
export class LegacyColdWallet {
77
@Column({
88
primary: true,
9-
type: "varchar",
9+
type: "citext",
1010
})
1111
public readonly address!: string;
1212

@@ -26,14 +26,14 @@ export class LegacyColdWallet {
2626
@Column({
2727
default: undefined,
2828
nullable: true,
29-
type: "varchar",
29+
type: "citext",
3030
})
3131
public readonly mergeInfoWalletAddress?: string | undefined;
3232

3333
@Column({
3434
default: undefined,
3535
nullable: true,
36-
type: "varchar",
36+
type: "citext",
3737
})
3838
public readonly mergeInfoTransactionHash?: string | undefined;
3939
}

packages/api-database/source/models/receipt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { bufferTransformer } from "../transformers/buffer.js";
88
export class Receipt {
99
@Column({
1010
primary: true,
11-
type: "varchar",
11+
type: "citext",
1212
})
1313
public readonly transactionHash!: string;
1414

@@ -39,7 +39,7 @@ export class Receipt {
3939
@Column({
4040
default: undefined,
4141
nullable: true,
42-
type: "varchar",
42+
type: "citext",
4343
})
4444
public readonly contractAddress: string | undefined;
4545

packages/api-database/source/models/transaction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { bufferTransformer } from "../transformers/buffer.js";
88
export class Transaction {
99
@Column({
1010
primary: true,
11-
type: "varchar",
11+
type: "citext",
1212
})
1313
public readonly hash!: string;
1414

1515
@Column({
1616
nullable: false,
17-
type: "varchar",
17+
type: "citext",
1818
})
1919
public readonly blockHash!: string;
2020

@@ -44,20 +44,20 @@ export class Transaction {
4444

4545
@Column({
4646
nullable: false,
47-
type: "varchar",
47+
type: "citext",
4848
})
4949
public readonly senderPublicKey!: string;
5050

5151
@Column({
5252
nullable: false,
53-
type: "varchar",
53+
type: "citext",
5454
})
5555
public readonly from!: string;
5656

5757
@Column({
5858
default: undefined,
5959
nullable: true,
60-
type: "varchar",
60+
type: "citext",
6161
})
6262
public readonly to!: string | undefined;
6363

packages/api-database/source/models/wallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { Column, Entity } from "typeorm";
66
export class Wallet {
77
@Column({
88
primary: true,
9-
type: "varchar",
9+
type: "citext",
1010
})
1111
public address!: string;
1212

1313
@Column({
1414
default: undefined,
1515
nullable: true,
16-
type: "varchar",
16+
type: "citext",
1717
})
1818
public publicKey!: string | undefined;
1919

packages/api-database/source/service-provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class ServiceProvider extends Providers.ServiceProvider {
109109
// Note: this only initializes the connection pool, etc. but does not run migrations.
110110
// Migrations are handled during bootstrap elsewhere in the main process (see sync.ts)
111111
await dataSource.initialize();
112+
await dataSource.createQueryRunner().query("CREATE EXTENSION IF NOT EXISTS citext;");
112113

113114
this.app.bind(Identifiers.DataSource).toConstantValue(dataSource);
114115
this.app.bind(Identifiers.Migrations).to(Migrations).inSingletonScope();

0 commit comments

Comments
 (0)