diff --git a/database/entity/0001-init_db/Transaction.ts b/database/entity/0001-init_db/Transaction.ts index 3c2397108..a33fbd0be 100644 --- a/database/entity/0001-init_db/Transaction.ts +++ b/database/entity/0001-init_db/Transaction.ts @@ -1,6 +1,6 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'typeorm' -import { TransactionCreation } from '../TransactionCreation' -import { TransactionSendCoin } from '../TransactionSendCoin' +import { TransactionCreation } from './TransactionCreation' +import { TransactionSendCoin } from './TransactionSendCoin' @Entity('transactions') export class Transaction extends BaseEntity { diff --git a/database/entity/0016-transaction_signatures/Transaction.ts b/database/entity/0016-transaction_signatures/Transaction.ts index 8c8251baf..5410d010b 100644 --- a/database/entity/0016-transaction_signatures/Transaction.ts +++ b/database/entity/0016-transaction_signatures/Transaction.ts @@ -1,6 +1,6 @@ import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'typeorm' -import { TransactionCreation } from '../TransactionCreation' -import { TransactionSendCoin } from '../TransactionSendCoin' +import { TransactionCreation } from '../0001-init_db/TransactionCreation' +import { TransactionSendCoin } from '../0001-init_db/TransactionSendCoin' @Entity('transactions') export class Transaction extends BaseEntity { diff --git a/database/entity/0024-combine_transaction_tables/Transaction.ts b/database/entity/0024-combine_transaction_tables/Transaction.ts new file mode 100644 index 000000000..fde1f3057 --- /dev/null +++ b/database/entity/0024-combine_transaction_tables/Transaction.ts @@ -0,0 +1,65 @@ +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'typeorm' + +@Entity('transactions') +export class Transaction extends BaseEntity { + // TODO the id is defined as bigint(20) - there might be problems with that: https://github.com/typeorm/typeorm/issues/2400 + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'transaction_type_id', unsigned: true, length: 10, nullable: false }) + transactionTypeId: number + + @Column({ name: 'user_id', unsigned: true, length: 10, nullable: false }) + userId: number + + @Column({ type: 'bigint', length: 20, nullable: false }) + amount: BigInt + + @Column({ name: 'tx_hash', type: 'binary', length: 48, default: null, nullable: true }) + txHash: Buffer + + @Column({ length: 255, nullable: false, collation: 'utf8mb4_unicode_ci' }) + memo: string + + @Column({ type: 'timestamp', nullable: false, default: () => 'CURRENT_TIMESTAMP' }) + received: Date + + @Column({ type: 'binary', length: 64, nullable: true, default: null }) + signature: Buffer + + @Column({ type: 'binary', length: 32, nullable: true, default: null }) + pubkey: Buffer + + @Column({ + name: 'creation_ident_hash', + type: 'binary', + length: 32, + nullable: true, + default: null, + }) + creationIdentHash: Buffer + + @Column({ name: 'creation_date', type: 'timestamp', nullable: true, default: null }) + creationDate: Date + + @Column({ + name: 'send_receiver_public_key', + type: 'binary', + length: 32, + nullable: true, + default: null, + }) + sendReceiverPublicKey: Buffer + + @Column({ + name: 'send_receiver_user_id', + unsigned: true, + length: 10, + nullable: true, + default: null, + }) + sendReceiverUserId: number + + @Column({ name: 'send_sender_final_balance', length: 20, nullable: true, default: null }) + sendSenderFinalBalance: BigInt +} diff --git a/database/entity/Transaction.ts b/database/entity/Transaction.ts index f17479f9f..5c9d2df88 100644 --- a/database/entity/Transaction.ts +++ b/database/entity/Transaction.ts @@ -1 +1 @@ -export { Transaction } from './0016-transaction_signatures/Transaction' +export { Transaction } from './0024-combine_transaction_tables/Transaction' diff --git a/database/entity/TransactionCreation.ts b/database/entity/TransactionCreation.ts deleted file mode 100644 index 100e948a1..000000000 --- a/database/entity/TransactionCreation.ts +++ /dev/null @@ -1 +0,0 @@ -export { TransactionCreation } from './0001-init_db/TransactionCreation' diff --git a/database/entity/TransactionSendCoin.ts b/database/entity/TransactionSendCoin.ts deleted file mode 100644 index 5c47d3961..000000000 --- a/database/entity/TransactionSendCoin.ts +++ /dev/null @@ -1 +0,0 @@ -export { TransactionSendCoin } from './0001-init_db/TransactionSendCoin' diff --git a/database/entity/index.ts b/database/entity/index.ts index 37fe6eb55..9371b5420 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -4,8 +4,6 @@ import { LoginEmailOptIn } from './LoginEmailOptIn' import { Migration } from './Migration' import { ServerUser } from './ServerUser' import { Transaction } from './Transaction' -import { TransactionCreation } from './TransactionCreation' -import { TransactionSendCoin } from './TransactionSendCoin' import { User } from './User' import { UserSetting } from './UserSetting' import { UserTransaction } from './UserTransaction' @@ -19,8 +17,6 @@ export const entities = [ Migration, ServerUser, Transaction, - TransactionCreation, - TransactionSendCoin, User, UserSetting, UserTransaction,