DripListModel.ts
1 import type { 2 CreationOptional, 3 InferAttributes, 4 InferCreationAttributes, 5 Sequelize, 6 } from 'sequelize'; 7 import { DataTypes, Model } from 'sequelize'; 8 import type { UUID } from 'crypto'; 9 import type { AccountId, Address, NftDriverId } from '../core/types'; 10 import getSchema from '../utils/getSchema'; 11 12 export default class DripListModel extends Model< 13 InferAttributes<DripListModel>, 14 InferCreationAttributes<DripListModel> 15 > { 16 declare public accountId: NftDriverId; 17 declare public isValid: boolean; 18 declare public name: string | null; 19 declare public creator: Address | null; 20 declare public description: string | null; 21 declare public ownerAddress: Address; 22 declare public ownerAccountId: AccountId; 23 declare public previousOwnerAddress: Address | null; 24 declare public latestVotingRoundId: UUID | null; 25 declare public isVisible: boolean; 26 declare public lastProcessedIpfsHash: string; 27 declare public lastProcessedVersion: 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 latestVotingRoundId: { 55 allowNull: true, 56 type: DataTypes.UUID, 57 }, 58 description: { 59 allowNull: true, 60 type: DataTypes.TEXT, 61 }, 62 creator: { 63 allowNull: true, 64 type: DataTypes.STRING, 65 }, 66 previousOwnerAddress: { 67 allowNull: true, 68 type: DataTypes.STRING, 69 }, 70 isVisible: { 71 allowNull: false, 72 type: DataTypes.BOOLEAN, 73 }, 74 lastProcessedIpfsHash: { 75 allowNull: false, 76 type: DataTypes.TEXT, 77 }, 78 lastProcessedVersion: { 79 allowNull: false, 80 type: DataTypes.BIGINT, 81 }, 82 createdAt: { 83 allowNull: false, 84 type: DataTypes.DATE, 85 }, 86 updatedAt: { 87 allowNull: false, 88 type: DataTypes.DATE, 89 }, 90 }, 91 { 92 sequelize, 93 schema: getSchema(), 94 tableName: 'drip_lists', 95 underscored: true, 96 timestamps: true, 97 indexes: [ 98 { 99 fields: ['ownerAddress'], 100 name: `idx_drip_lists_owner_address`, 101 where: { 102 isValid: true, 103 }, 104 }, 105 ], 106 }, 107 ); 108 } 109 }