Skip to content

Commit

Permalink
feat: add hasData and typeScript to output entity
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 30, 2019
1 parent 6c783e3 commit 9fe535b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/neuron-wallet/src/database/chain/entities/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ export default class Output extends BaseEntity {
})
status!: string

@Column({
type: 'simple-json',
nullable: true,
})
typeScript: Script | null = null

@Column({
type: 'boolean',
})
hasData!: boolean

public outPoint(): OutPoint {
return {
txHash: this.outPointTxHash,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {MigrationInterface, QueryRunner, TableColumn} from "typeorm";

export class AddTypeAndHasData1567144517514 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.addColumn('output', new TableColumn({
name: 'typeScript',
type: 'varchar',
isNullable: true,
}))

await queryRunner.addColumn('output', new TableColumn({
name: 'hasData',
type: 'boolean',
default: false,
}))
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropColumn('output', 'hasData')
await queryRunner.dropColumn('output', 'typeScript')
}

}
3 changes: 2 additions & 1 deletion packages/neuron-wallet/src/database/chain/ormconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Input from './entities/input'
import Output from './entities/output'
import SyncInfo from './entities/sync-info'
import { InitMigration1566959757554 } from './migrations/1566959757554-InitMigration'
import { AddTypeAndHasData1567144517514 } from './migrations/1567144517514-AddTypeAndHasData'

export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError'

Expand All @@ -29,7 +30,7 @@ const connectOptions = async (genesisBlockHash: string): Promise<SqliteConnectio
type: 'sqlite',
database: dbPath(genesisBlockHash),
entities: [Transaction, Input, Output, SyncInfo],
migrations: [InitMigration1566959757554],
migrations: [InitMigration1566959757554, AddTypeAndHasData1567144517514],
logging,
}
}
Expand Down

0 comments on commit 9fe535b

Please sign in to comment.