EcosystemMainAccountModel.ts
1 import type { 2 CreationOptional, 3 InferAttributes, 4 InferCreationAttributes, 5 Sequelize, 6 } from 'sequelize'; 7 import { DataTypes, Model } from 'sequelize'; 8 import type { AccountId, Address, NftDriverId } from '../core/types'; 9 import getSchema from '../utils/getSchema'; 10 11 export default class EcosystemMainAccountModel extends Model< 12 InferAttributes<EcosystemMainAccountModel>, 13 InferCreationAttributes<EcosystemMainAccountModel> 14 > { 15 declare public accountId: NftDriverId; 16 declare public isValid: boolean; 17 declare public name: string | null; 18 declare public creator: Address | null; 19 declare public description: string | null; 20 declare public ownerAddress: Address; 21 declare public ownerAccountId: AccountId; 22 declare public previousOwnerAddress: Address; 23 declare public isVisible: boolean; 24 declare public lastProcessedIpfsHash: string; 25 declare public lastProcessedVersion: string; 26 declare public avatar: string; 27 declare public color: string; 28 declare public createdAt: CreationOptional<Date>; 29 declare public updatedAt: CreationOptional<Date>; 30 31 public static initialize(sequelize: Sequelize): void { 32 this.init( 33 { 34 accountId: { 35 primaryKey: true, 36 type: DataTypes.STRING, 37 }, 38 isValid: { 39 allowNull: false, 40 type: DataTypes.BOOLEAN, 41 }, 42 ownerAddress: { 43 allowNull: false, 44 type: DataTypes.STRING, 45 }, 46 ownerAccountId: { 47 allowNull: false, 48 type: DataTypes.STRING, 49 }, 50 name: { 51 allowNull: true, 52 type: DataTypes.STRING, 53 }, 54 description: { 55 allowNull: true, 56 type: DataTypes.TEXT, 57 }, 58 creator: { 59 allowNull: true, 60 type: DataTypes.STRING, 61 }, 62 previousOwnerAddress: { 63 allowNull: false, 64 type: DataTypes.STRING, 65 }, 66 isVisible: { 67 allowNull: false, 68 type: DataTypes.BOOLEAN, 69 }, 70 lastProcessedIpfsHash: { 71 allowNull: false, 72 type: DataTypes.TEXT, 73 }, 74 lastProcessedVersion: { 75 allowNull: false, 76 type: DataTypes.BIGINT, 77 }, 78 avatar: { 79 allowNull: false, 80 type: DataTypes.STRING, 81 }, 82 color: { 83 allowNull: false, 84 type: DataTypes.STRING, 85 }, 86 createdAt: { 87 allowNull: false, 88 type: DataTypes.DATE, 89 }, 90 updatedAt: { 91 allowNull: false, 92 type: DataTypes.DATE, 93 }, 94 }, 95 { 96 sequelize, 97 schema: getSchema(), 98 tableName: 'ecosystem_main_accounts', 99 underscored: true, 100 timestamps: true, 101 indexes: [ 102 { 103 fields: ['ownerAddress'], 104 name: `idx_ecosystem_main_accounts_owner_address`, 105 where: { 106 isValid: true, 107 }, 108 }, 109 ], 110 }, 111 ); 112 } 113 }