aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized/deposits.js
blob: ec9472d89c492ab130a7e53aa5d2b149fb5f5e2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { DataTypes } = require('sequelize');

const attributes = {
  id: {
    type: DataTypes.INTEGER(11),
    primaryKey: true,
    autoIncrement: true,
    allowNull: false
  },
  user_id: {
    type: DataTypes.INTEGER(11),
    references: { model: User, key: 'id' },
    allowNull: false,
    comment: "Referral granted to this user (updated when token used)"
  },
  amount: {
    type: DataTypes.DECIMAL(10,2),
    allowNull: false
  },
  deposit_code: {
    type: DataTypes.STRING(255),
    comment: "Unique randomly generated code to be put in the interac deposit reference/message to link the deposit to this record/user",
  },
  status: {
    type: DataTypes.ENUM,
    values: ['pending', 'credited', 'failed'],
    defaultValue: 'pending'
  }
}

const options = {
  tableName: "deposits",
  comment: "",
  timestamps: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at',
  indexes: [
    {
      unique: true,
      fields: ['code']
    }
  ]
};

db["Deposit"] = db.define("deposits_model", attributes, options);