From 96c15b5cbc9a6c3f0f1163b62368a2b0c2664583 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 25 Aug 2023 13:06:58 +0200 Subject: [PATCH] change some names for more clarity --- dlt-database/entity/0001-init_db/Account.ts | 14 +++++++------- dlt-database/entity/0001-init_db/Community.ts | 10 +++++----- .../entity/0001-init_db/ConfirmedTransaction.ts | 12 ++++++------ .../{TransactionDraft.ts => TransactionRecipe.ts} | 14 +++++++------- dlt-database/entity/TransactionDraft.ts | 1 - dlt-database/entity/TransactionRecipe.ts | 1 + dlt-database/migrations/0001-init_db.ts | 10 +++++----- dlt-database/package.json | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) rename dlt-database/entity/0001-init_db/{TransactionDraft.ts => TransactionRecipe.ts} (88%) delete mode 100644 dlt-database/entity/TransactionDraft.ts create mode 100644 dlt-database/entity/TransactionRecipe.ts diff --git a/dlt-database/entity/0001-init_db/Account.ts b/dlt-database/entity/0001-init_db/Account.ts index dba7b58e1..23636dd56 100644 --- a/dlt-database/entity/0001-init_db/Account.ts +++ b/dlt-database/entity/0001-init_db/Account.ts @@ -12,7 +12,7 @@ import { } from 'typeorm' import { User } from './User' import { Community } from './Community' -import { TransactionDraft } from './TransactionDraft' +import { TransactionRecipe } from './TransactionRecipe' import { ConfirmedTransaction } from './ConfirmedTransaction' @Entity('accounts') @@ -28,8 +28,8 @@ export class Account { @Column({ name: 'user_id', type: 'int', unsigned: true, nullable: true }) userId?: number - @Column({ name: 'account_nr', type: 'int', unsigned: true, default: 0 }) - accountNr: number + @Column({ name: 'derivation_index', type: 'int', unsigned: true }) + derivationIndex: number @Column({ type: 'binary', length: 32, unique: true }) pubkey: Buffer @@ -62,11 +62,11 @@ export class Account { }) accountCommunities: Community[] - @OneToMany(() => TransactionDraft, (draft) => draft.signingAccount) - transactionDraftsSigning?: TransactionDraft[] + @OneToMany(() => TransactionRecipe, (recipe) => recipe.signingAccount) + transactionRecipesSigning?: TransactionRecipe[] - @OneToMany(() => TransactionDraft, (draft) => draft.recipientAccount) - transactionDraftsRecipient?: TransactionDraft[] + @OneToMany(() => TransactionRecipe, (recipe) => recipe.recipientAccount) + transactionRecipesRecipient?: TransactionRecipe[] @OneToMany(() => ConfirmedTransaction, (transaction) => transaction.account) confirmedTransactions?: ConfirmedTransaction[] diff --git a/dlt-database/entity/0001-init_db/Community.ts b/dlt-database/entity/0001-init_db/Community.ts index 8c3d36c32..a75a51f27 100644 --- a/dlt-database/entity/0001-init_db/Community.ts +++ b/dlt-database/entity/0001-init_db/Community.ts @@ -10,7 +10,7 @@ import { JoinTable, } from 'typeorm' import { Account } from './Account' -import { TransactionDraft } from './TransactionDraft' +import { TransactionRecipe } from './TransactionRecipe' @Entity('communities') export class Community { @@ -60,9 +60,9 @@ export class Community { }) communityAccounts: Account[] - @OneToMany(() => TransactionDraft, (draft) => draft.senderCommunity) - transactionDraftsSender?: TransactionDraft[] + @OneToMany(() => TransactionRecipe, (recipe) => recipe.senderCommunity) + transactionRecipesSender?: TransactionRecipe[] - @OneToMany(() => TransactionDraft, (draft) => draft.recipientCommunity) - transactionDraftsRecipient?: TransactionDraft[] + @OneToMany(() => TransactionRecipe, (recipe) => recipe.recipientCommunity) + transactionRecipesRecipient?: TransactionRecipe[] } diff --git a/dlt-database/entity/0001-init_db/ConfirmedTransaction.ts b/dlt-database/entity/0001-init_db/ConfirmedTransaction.ts index 4f4137136..aff1ac07d 100644 --- a/dlt-database/entity/0001-init_db/ConfirmedTransaction.ts +++ b/dlt-database/entity/0001-init_db/ConfirmedTransaction.ts @@ -11,19 +11,19 @@ import { Decimal } from 'decimal.js-light' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' import { Account } from './Account' -import { TransactionDraft } from './TransactionDraft' +import { TransactionRecipe } from './TransactionRecipe' @Entity('confirmed_transactions') export class ConfirmedTransaction { @PrimaryGeneratedColumn('increment', { unsigned: true, type: 'bigint' }) id: number - @OneToOne(() => TransactionDraft, (draft) => draft.confirmedTransaction) - @JoinColumn({ name: 'transaction_draft_id' }) - transactionDraft: TransactionDraft + @OneToOne(() => TransactionRecipe, (recipe) => recipe.confirmedTransaction) + @JoinColumn({ name: 'transaction_recipe_id' }) + transactionRecipe: TransactionRecipe - @Column({ name: 'transaction_draft_id', type: 'int', unsigned: true }) - transactionDraftId: number + @Column({ name: 'transaction_recipe_id', type: 'int', unsigned: true }) + transactionRecipeId: number @Column({ type: 'bigint' }) nr: number diff --git a/dlt-database/entity/0001-init_db/TransactionDraft.ts b/dlt-database/entity/0001-init_db/TransactionRecipe.ts similarity index 88% rename from dlt-database/entity/0001-init_db/TransactionDraft.ts rename to dlt-database/entity/0001-init_db/TransactionRecipe.ts index d489e711c..52419f653 100644 --- a/dlt-database/entity/0001-init_db/TransactionDraft.ts +++ b/dlt-database/entity/0001-init_db/TransactionRecipe.ts @@ -14,36 +14,36 @@ import { Account } from './Account' import { Community } from './Community' import { ConfirmedTransaction } from './ConfirmedTransaction' -@Entity('transaction_drafts') -export class TransactionDraft { +@Entity('transaction_recipes') +export class TransactionRecipe { @PrimaryGeneratedColumn('increment', { unsigned: true, type: 'bigint' }) id: number @Column({ name: 'iota_message_id', type: 'binary', length: 32, nullable: true }) iotaMessageId?: Buffer - @ManyToOne(() => Account, (account) => account.transactionDraftsSigning) + @ManyToOne(() => Account, (account) => account.transactionRecipesSigning) @JoinColumn({ name: 'signing_account_id' }) signingAccount: Account @Column({ name: 'signing_account_id', type: 'int', unsigned: true }) signingAccountId: number - @ManyToOne(() => Account, (account) => account.transactionDraftsRecipient) + @ManyToOne(() => Account, (account) => account.transactionRecipesRecipient) @JoinColumn({ name: 'recipient_account_id' }) recipientAccount?: Account @Column({ name: 'recipient_account_id', type: 'int', unsigned: true, nullable: true }) recipientAccountId?: number - @ManyToOne(() => Community, (community) => community.transactionDraftsSender) + @ManyToOne(() => Community, (community) => community.transactionRecipesSender) @JoinColumn({ name: 'sender_community_id' }) senderCommunity: Community @Column({ name: 'sender_community_id', type: 'int', unsigned: true }) senderCommunityId: number - @ManyToOne(() => Community, (community) => community.transactionDraftsRecipient) + @ManyToOne(() => Community, (community) => community.transactionRecipesRecipient) @JoinColumn({ name: 'recipient_community_id' }) recipientCommunity?: Community @@ -74,6 +74,6 @@ export class TransactionDraft { @Column({ name: 'protocol_version', type: 'int', default: 1 }) protocolVersion: number - @OneToOne(() => ConfirmedTransaction, (transaction) => transaction.transactionDraft) + @OneToOne(() => ConfirmedTransaction, (transaction) => transaction.transactionRecipe) confirmedTransaction?: ConfirmedTransaction } diff --git a/dlt-database/entity/TransactionDraft.ts b/dlt-database/entity/TransactionDraft.ts deleted file mode 100644 index 006d66930..000000000 --- a/dlt-database/entity/TransactionDraft.ts +++ /dev/null @@ -1 +0,0 @@ -export { TransactionDraft } from './0001-init_db/TransactionDraft' diff --git a/dlt-database/entity/TransactionRecipe.ts b/dlt-database/entity/TransactionRecipe.ts new file mode 100644 index 000000000..e59a09ef9 --- /dev/null +++ b/dlt-database/entity/TransactionRecipe.ts @@ -0,0 +1 @@ +export { TransactionRecipe } from './0001-init_db/TransactionRecipe' diff --git a/dlt-database/migrations/0001-init_db.ts b/dlt-database/migrations/0001-init_db.ts index 82e280fcb..e66c2f3f6 100644 --- a/dlt-database/migrations/0001-init_db.ts +++ b/dlt-database/migrations/0001-init_db.ts @@ -30,7 +30,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis CREATE TABLE IF NOT EXISTS \`accounts\` ( \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT, \`user_id\` int(10) unsigned DEFAULT NULL, - \`account_nr\` int(10) unsigned NOT NULL DEFAULT 0, + \`derivation_index\` int(10) unsigned NOT NULL, \`pubkey\` binary(32) NOT NULL, \`type\` tinyint unsigned NOT NULL, \`created_at\` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -72,7 +72,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`) await queryFn(` - CREATE TABLE IF NOT EXISTS \`transaction_drafts\` ( + CREATE TABLE IF NOT EXISTS \`transaction_recipes\` ( \`id\` bigint unsigned NOT NULL AUTO_INCREMENT, \`iota_message_id\` binary(32) DEFAULT NULL, \`signing_account_id\` int(10) unsigned NOT NULL, @@ -95,7 +95,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn(` CREATE TABLE IF NOT EXISTS \`confirmed_transactions\` ( \`id\` bigint unsigned NOT NULL AUTO_INCREMENT, - \`transaction_draft_id\` bigint unsigned NOT NULL, + \`transaction_recipe_id\` bigint unsigned NOT NULL, \`nr\` bigint unsigned NOT NULL, \`running_hash\` binary(48) NOT NULL, \`account_id\` int(10) unsigned NOT NULL, @@ -103,7 +103,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`iota_milestone\` bigint NOT NULL, \`confirmed_at\` datetime NOT NULL, PRIMARY KEY (\`id\`), - FOREIGN KEY (\`transaction_draft_id\`) REFERENCES transaction_drafts(id), + FOREIGN KEY (\`transaction_recipe_id\`) REFERENCES transaction_recipes(id), FOREIGN KEY (\`account_id\`) REFERENCES accounts(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;`) } @@ -113,7 +113,7 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom await queryFn(`DROP TABLE IF EXISTS \`users\`;`) await queryFn(`DROP TABLE IF EXISTS \`accounts\`;`) await queryFn(`DROP TABLE IF EXISTS \`account_community\`;`) - await queryFn(`DROP TABLE IF EXISTS \`transaction_drafts\`;`) + await queryFn(`DROP TABLE IF EXISTS \`transaction_recipes\`;`) await queryFn(`DROP TABLE IF EXISTS \`confirmed_transactions\`;`) await queryFn(`DROP TABLE IF EXISTS \`community\`;`) } diff --git a/dlt-database/package.json b/dlt-database/package.json index 2cf76cd9e..f60587dad 100644 --- a/dlt-database/package.json +++ b/dlt-database/package.json @@ -8,7 +8,7 @@ "license": "Apache-2.0", "private": false, "scripts": { - "build": "mkdir -p build/src/config/ && tsc --build", + "build": "tsc --build", "clean": "tsc --build --clean", "up": "cross-env TZ=UTC node build/src/index.js up", "down": "cross-env TZ=UTC node build/src/index.js down",