db update

This commit is contained in:
einhorn_b 2023-12-17 16:31:54 +01:00
parent 3d245dc3af
commit c5c073bff4
3 changed files with 8 additions and 9 deletions

View File

@ -26,8 +26,8 @@ export class Account extends BaseEntity {
@Column({ name: 'user_id', type: 'int', unsigned: true, nullable: true })
userId?: number
@Column({ name: 'derivation_index', type: 'int', unsigned: true, nullable: true })
derivationIndex?: number
@Column({ name: 'derivation_index', type: 'int', unsigned: true })
derivationIndex: number
@Column({ name: 'derive2_pubkey', type: 'binary', length: 32, unique: true })
derive2Pubkey: Buffer

View File

@ -5,7 +5,7 @@ export class InvalidTransaction extends BaseEntity {
@PrimaryGeneratedColumn('increment', { unsigned: true, type: 'bigint' })
id: number
@Column({ name: 'iota_message_id', type: 'binary', length: 32 })
@Column({ name: 'iota_message_id', type: 'binary', length: 32, unique: true })
iotaMessageId: Buffer
@Column({ name: 'error_message', type: 'varchar', length: 255 })

View File

@ -13,9 +13,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
;
`)
await queryFn(
`ALTER TABLE \`accounts\` MODIFY COLUMN \`derivation_index\` int(10) unsigned NULL DEFAULT NULL;`,
)
await queryFn(
`ALTER TABLE \`accounts\` ADD COLUMN \`balance_created_at\` decimal(40,20) NOT NULL DEFAULT 0 AFTER \`balance_confirmed_at_date\`;`,
)
@ -30,6 +27,9 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
`ALTER TABLE \`invalid_transactions\` ADD COLUMN \`error_message\` varchar(255) NOT NULL;`,
)
await queryFn(`ALTER TABLE \`invalid_transactions\` DROP INDEX \`iota_message_id\`;`)
await queryFn(`ALTER TABLE \`invalid_transactions\` ADD UNIQUE(\`iota_message_id\`);`)
await queryFn(
`CREATE TABLE \`transactions\` (
\`id\` bigint unsigned NOT NULL AUTO_INCREMENT,
@ -120,12 +120,11 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom
;
`)
await queryFn(
`ALTER TABLE \`accounts\` MODIFY COLUMN \`derivation_index\` int(10) unsigned NOT NULL;`,
)
await queryFn(`ALTER TABLE \`accounts\` DROP COLUMN \`balance_created_at\`;`)
await queryFn(`ALTER TABLE \`accounts\` DROP COLUMN \`balance_created_at_date\`;`)
await queryFn(`ALTER TABLE \`invalid_transactions\` DROP COLUMN \`error_message\`;`)
await queryFn(`ALTER TABLE \`invalid_transactions\` DROP INDEX \`iota_message_id\`;`)
await queryFn(`ALTER TABLE \`invalid_transactions\` ADD INDEX(\`iota_message_id\`); `)
await queryFn(`DROP TABLE \`transactions\`;`)
await queryFn(