overwork dlt_transactions table and entity

This commit is contained in:
Claus-Peter Huebner 2023-07-21 19:47:47 +02:00
parent b0a6d83f61
commit c46c7df8ff
7 changed files with 14 additions and 46 deletions

View File

@ -12,7 +12,7 @@ Decimal.set({
})
const constants = {
DB_VERSION: '0069-add_user_roles_table',
DB_VERSION: '0070-add_dlt_transactions_table',
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info

View File

@ -1,6 +1,4 @@
import Decimal from 'decimal.js-light'
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'
import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer'
import { Transaction } from '../Transaction'
@Entity('dlt_transactions', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
@ -11,47 +9,18 @@ export class DltTransaction extends BaseEntity {
@Column({ name: 'transaction_id', type: 'int', unsigned: true, nullable: false })
transactionId: number
@Column({ name: 'message_id', length: 40, nullable: false, collation: 'utf8mb4_unicode_ci' })
@Column({
name: 'message_id',
length: 40,
nullable: true,
default: null,
collation: 'utf8mb4_unicode_ci',
})
messageId: string
@Column({ name: 'verified', type: 'bool', nullable: false, default: false })
verified: boolean
@Column({
name: 'community_balance',
type: 'decimal',
precision: 40,
scale: 20,
nullable: true,
transformer: DecimalTransformer,
})
communityBalance: Decimal | null
@Column({
name: 'community_balance_date',
type: 'datetime',
nullable: true,
})
CommunityBalanceDate: Date | null
@Column({
name: 'community_balance_decay',
type: 'decimal',
precision: 40,
scale: 20,
nullable: true,
transformer: DecimalTransformer,
})
CommunityBalanceDecay: Decimal | null
@Column({
name: 'community_balance_decay_start',
type: 'datetime',
nullable: true,
default: null,
})
CommunityBalanceDecayStart: Date | null
@Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP(3)', nullable: false })
createdAt: Date

View File

@ -0,0 +1 @@
export { DltTransaction } from './0070-add_dlt_transactions_table/DltTransaction'

View File

@ -12,12 +12,14 @@ import { ContributionMessage } from './ContributionMessage'
import { Community } from './Community'
import { FederatedCommunity } from './FederatedCommunity'
import { UserRole } from './UserRole'
import { DltTransaction } from './DltTransaction'
export const entities = [
Community,
Contribution,
ContributionLink,
ContributionMessage,
DltTransaction,
Event,
FederatedCommunity,
LoginElopageBuys,

View File

@ -6,12 +6,8 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
CREATE TABLE dlt_transactions (
id int unsigned NOT NULL AUTO_INCREMENT,
transactions_id int(10) unsigned NOT NULL,
message_id varchar(40) NOT NULL,
message_id varchar(40) NULL DEFAULT NULL,
verified tinyint(4) NOT NULL DEFAULT 0,
community_balance decimal(40,20) DEFAULT NULL NULL,
community_balance_date datetime(3) DEFAULT NULL NULL,
community_balance_decay decimal(40,20) DEFAULT NULL NULL,
community_balance_decay_start datetime(3) DEFAULT NULL NULL,
created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
verified_at datetime(3),
PRIMARY KEY (id)

View File

@ -4,7 +4,7 @@ import dotenv from 'dotenv'
dotenv.config()
const constants = {
DB_VERSION: '0069-add_user_roles_table',
DB_VERSION: '0070-add_dlt_transactions_table',
LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info
LOG_LEVEL: process.env.LOG_LEVEL || 'info',

View File

@ -11,7 +11,7 @@ Decimal.set({
*/
const constants = {
DB_VERSION: '0069-add_user_roles_table',
DB_VERSION: '0070-add_dlt_transactions_table',
// DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info