diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/referrals.sql | 18 | ||||
| -rw-r--r-- | db/normalized/accounts.js | 13 | ||||
| -rw-r--r-- | db/normalized/assets.js | 27 | ||||
| -rw-r--r-- | db/normalized/deposits.js | 6 |
4 files changed, 21 insertions, 43 deletions
diff --git a/db/migrations/referrals.sql b/db/migrations/referrals.sql index b755000a..b59ffdf9 100644 --- a/db/migrations/referrals.sql +++ b/db/migrations/referrals.sql @@ -1,5 +1,5 @@ -- Note: Adding FK contraints may cause issues, so I have commented them out for now, but these need to be established - +DROP TABLE IF EXISTS `referrals`; CREATE TABLE `referrals` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `token` varchar(255) DEFAULT NULL UNIQUE, @@ -7,15 +7,16 @@ CREATE TABLE `referrals` ( `status` enum('pending','active','expired','cancelled') DEFAULT NULL, `sponsor_id` int(11) NOT NULL, `user_id` int(11) DEFAULT NULL, - `created_at` datetime DEFAULT CURRENT_TIMESTAMP, - `updated_at` datetime DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp, PRIMARY KEY (`id`), KEY `sponsor_id` (`sponsor_id`), KEY `user_id` (`user_id`) -- FOREIGN KEY (`user_id`) REFERENCES `users` (`id`), -- FOREIGN KEY (`sponsor_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; +DROP TABLE IF EXISTS `waiting_list`; CREATE TABLE `waiting_list` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `email` varchar(255) DEFAULT NULL UNIQUE, @@ -23,8 +24,11 @@ CREATE TABLE `waiting_list` ( `user_id` int(11) DEFAULT NULL, `status` enum('pending','contacted','registered','cancelled') DEFAULT 'pending', `notes` text DEFAULT NULL, - `created_at` datetime DEFAULT CURRENT_TIMESTAMP, - `updated_at` datetime DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp, PRIMARY KEY (`id`) -- CONSTRAINT `user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
\ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 + +ALTER TABLE users ADD `email` varchar(255) DEFAULT NULL; +ALTER TABLE users ADD `sms` varchar(255) DEFAULT NULL; diff --git a/db/normalized/accounts.js b/db/normalized/accounts.js index 7eabaaa0..36e332d7 100644 --- a/db/normalized/accounts.js +++ b/db/normalized/accounts.js @@ -18,11 +18,10 @@ const attributes = { allowNull: false, comment: "Referral granted to this user (updated when token used)" }, - asset_id: { - type: DataTypes.INTEGER(11), - references: { model: Asset, key: 'code' }, + asset: { + type: DataTypes.STRING, allowNull: false, - comment: "Reference to asset" + comment: "Reference to liquid asset on liquid blockchain" }, balance: { type: DataTypes.DOUBLE, @@ -31,12 +30,14 @@ const attributes = { pending: { type: DataTypes.DOUBLE, allowNull: false, - comment: "What is this ?" + comment: "Pending balance indicates that the transaction has been detected on the blockchain but not confirmed" }, + /* DEPRECATED precision: { type: DataTypes.INTEGER(11), - comment: "what is this for ? ... is it unique for each account ?" + comment: "The decimal precision for the liquid asset " } + */ } const options = { tableName: "accounts", diff --git a/db/normalized/assets.js b/db/normalized/assets.js deleted file mode 100644 index 63866b4f..00000000 --- a/db/normalized/assets.js +++ /dev/null @@ -1,27 +0,0 @@ -const { DataTypes } = require('sequelize'); - -const attributes = { - code: { - type: DataTypes.INTEGER(11), - primaryKey: true, - allowNull: false - }, - name: { - type: DataTypes.STRING(255) - } -} -const options = { - tableName: "assets", - comment: "", - timestamps: true, - createdAt: 'created_at', - updatedAt: 'updated_at', - indexes: [ - { - unique: true, - fields: ['code'] - } - ] -}; - -db["Asset"] = db.define("assets_model", attributes, options); diff --git a/db/normalized/deposits.js b/db/normalized/deposits.js index 7259abc2..ec9472d8 100644 --- a/db/normalized/deposits.js +++ b/db/normalized/deposits.js @@ -17,9 +17,9 @@ const attributes = { type: DataTypes.DECIMAL(10,2), allowNull: false }, - code: { - // is this unique ? - type: DataTypes.STRING(255) + 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, |
