From 2e18dc7a532d07d6e53581e5076c7d61a45d6d65 Mon Sep 17 00:00:00 2001 From: Ran Guin Date: Tue, 11 May 2021 18:28:25 -0700 Subject: add first draft of normalized schema --- db/normalized/deposits.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 db/normalized/deposits.js (limited to 'db/normalized/deposits.js') diff --git a/db/normalized/deposits.js b/db/normalized/deposits.js new file mode 100644 index 00000000..7259abc2 --- /dev/null +++ b/db/normalized/deposits.js @@ -0,0 +1,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 + }, + code: { + // is this unique ? + type: DataTypes.STRING(255) + }, + 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); -- cgit v1.2.3