aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized/users.js
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-07-14 18:00:30 -0700
committerRan Guin <[email protected]>2021-07-14 18:00:30 -0700
commit4eacfda951f8275ac4f3a1283368884e53285ed0 (patch)
tree149e15bc2292b65756dff6323cb3778c9dc89f54 /db/normalized/users.js
parent826da4a8f7d791b06bb53346597ab0ed51b6362e (diff)
downloadcoinos-server-4eacfda951f8275ac4f3a1283368884e53285ed0.tar.gz
coinos-server-4eacfda951f8275ac4f3a1283368884e53285ed0.zip
update normalized models
Diffstat (limited to 'db/normalized/users.js')
-rw-r--r--db/normalized/users.js216
1 files changed, 14 insertions, 202 deletions
diff --git a/db/normalized/users.js b/db/normalized/users.js
index d5b5240f..2c2004c0 100644
--- a/db/normalized/users.js
+++ b/db/normalized/users.js
@@ -1,206 +1,18 @@
-const { DataTypes } = require('sequelize');
+exports.up = function(knex) {
+ return knex.schema.createTable('users', function(t) {
+ t.increments('id').unsigned().primary();
-const attributes = {
- id: {
- type: DataTypes.INTEGER(11),
- primaryKey: true,
- autoIncrement: true,
- allowNull: false
- },
- uuid: {
- type: DataTypes.STRING(255),
- allowNull: false,
- comment: "unique UUID as more secure reference"
- },
- password: {
- type: DataTypes.STRING(255), // Encrypted Password type ??
- allowNull: false,
- validate: {
- len: [8, 255]
- }
- },
- email: {
- type: DataTypes.STRING(255),
- validate: {
- isEmail: true
- }
- },
- sms: {
- type: DataTypes.STRING(255),
- validate: {
- is: /^[0-9]+$/ // replace spaces, brackets, dashes dynamically prior to create
- }
- },
- email_verified: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- },
- sms_verified: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- },
- access: {
- type: DataTypes.ENUM,
- values: ['Member', 'Tester', 'Admin'],
- defaultValue: 'Member'
- }
-}
+ t.string('uuid').notNull().index();
+ t.string('username').notNull().index();
+ t.string('password').notNull();
+ t.string('email').nullable().index();
+ t.string('phone').nullable();
+ t.enum('access', ['Anonymous', 'Registered', 'Admin']).notNull().defaultTo('Anonymous');
-const options = {
- tableName: "users",
- comment: "",
- timestamps: true,
- createdAt: 'created_at',
- updatedAt: 'updated_at',
- indexes: [
- {fields: ['uuid', 'email']}
- ]
+ t.timestamps();
+ })
};
-db["User"] = db.define("users_model", attributes, options);
-
-
- // *** Move to user_preferences ***
-// unit: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: 'SAT',
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "unit"
-// },
-// currency: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: "CAD",
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "currency"
-// },
-// currencies: {
-// type: DataTypes.JSON,
-// allowNull: false,
-// defaultValue: ["USD"],
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "currencies"
-// },
-
-// fiat: { ???
-// type: DataTypes.BOOLEAN,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "fiat"
-// },
-
-// ** Remove - redundant / unnecessary **
-// account_id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "account_id"
-// },
-// twofa: { = otp_secret NOT NULL
-// type: DataTypes.INTEGER(1),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "twofa"
-// },
-
-// *** Move to user_keys ***
-
-// otpsecret: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: "CAD",
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "otpsecret"
-// },
-// pin: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "pin"
-// },
-// seed: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "seed"
-// },
-
-// ** What are these exactly ... ? **
-// ip: { ??
-// type: DataTypes.INTEGER.UNSIGNED,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "ip"
-// },
-
-// index: {
-// type: DataTypes.INTEGER,
-// allowNull: true,
-// defaultValue: 0,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "index"
-// },
-
-// };
-
-// *** Add breakout table
-// subscriptions: {
-// type: DataTypes.TEXT,
-// get: function() {
-// return JSON.parse(this.getDataValue("subscriptions"));
-// },
-// set: function(value) {
-// return this.setDataValue("subscriptions", JSON.stringify(value));
-// },
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "subscriptions"
-// },
-
- // *** replaced with other field(s) ***
- // locked: { - embed logic with user status (?)
- // type: DataTypes.BOOLEAN,
- // allowNull: true,
- // defaultValue: false,
- // primaryKey: false,
- // autoIncrement: false,
- // comment: null,
- // field: "locked"
- // },
-
-
-
+exports.down = function(knex) {
+ return knex.schema.dropTable('users');
+}; \ No newline at end of file