From d079d8c7c4c1efcb39f05255b2d025605dbbd790 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 9 Oct 2020 10:04:27 -0700 Subject: proposals -> orders --- db/index.js | 12 ++--- db/models/orders.js | 111 +++++++++++++++++++++++++++++++++++++++ db/models/proposals.js | 138 ------------------------------------------------- 3 files changed, 117 insertions(+), 144 deletions(-) create mode 100644 db/models/orders.js delete mode 100644 db/models/proposals.js (limited to 'db') diff --git a/db/index.js b/db/index.js index 0772bfc7..2ee61643 100644 --- a/db/index.js +++ b/db/index.js @@ -13,10 +13,10 @@ require("./models/codes.js"); require("./models/invoices.js"); require("./models/keys.js"); require("./models/payments.js"); -require("./models/proposals.js"); +require("./models/orders.js"); require("./models/users.js"); -const { User, Account, Payment, Invoice, Key, Proposal } = db; +const { User, Account, Payment, Invoice, Key, Order } = db; User.hasMany(Account, { as: "accounts", @@ -73,19 +73,19 @@ Payment.belongsTo(User, { foreignKey: "user_id" }); -Proposal.belongsTo(User, { +Order.belongsTo(User, { as: "user", foreignKey: "user_id" }); -Proposal.belongsTo(Account, { +Order.belongsTo(Account, { as: "acc1", foreignKey: "a1_id" }); -Proposal.belongsTo(Account, { +Order.belongsTo(Account, { as: "acc2", foreignKey: "a2_id" }); -db.Proposal = Proposal; +db.Order = Order; diff --git a/db/models/orders.js b/db/models/orders.js new file mode 100644 index 00000000..e9c701a3 --- /dev/null +++ b/db/models/orders.js @@ -0,0 +1,111 @@ +const { DataTypes } = require("sequelize"); + +const attributes = { + id: { + type: DataTypes.INTEGER(11), + allowNull: false, + defaultValue: null, + primaryKey: true, + autoIncrement: true, + comment: null, + field: "id" + }, + a1_id: { + type: DataTypes.INTEGER(11), + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "a1_id" + }, + a2_id: { + type: DataTypes.INTEGER(11), + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "a2_id" + }, + user_id: { + type: DataTypes.INTEGER(11), + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "user_id" + }, + completedAt: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "completedAt" + }, + createdAt: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "createdAt" + }, + updatedAt: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "updatedAt" + }, + v1: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "v1" + }, + v2: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "v2" + }, + rate: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "rate" + }, + accepted: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "accepted" + }, +}; + +const options = { + tableName: "orders", + comment: "", + indexes: [] +}; + +db.Order = db.define("orders_model", attributes, options); diff --git a/db/models/proposals.js b/db/models/proposals.js deleted file mode 100644 index 1f93ba06..00000000 --- a/db/models/proposals.js +++ /dev/null @@ -1,138 +0,0 @@ -const { DataTypes } = require("sequelize"); - -const attributes = { - id: { - type: DataTypes.INTEGER(11), - allowNull: false, - defaultValue: null, - primaryKey: true, - autoIncrement: true, - comment: null, - field: "id" - }, - a1_id: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "a1_id" - }, - a2_id: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "a2_id" - }, - user_id: { - type: DataTypes.INTEGER(11), - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "user_id" - }, - completedAt: { - type: DataTypes.DATE, - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "completedAt" - }, - createdAt: { - type: DataTypes.DATE, - allowNull: false, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "createdAt" - }, - updatedAt: { - type: DataTypes.DATE, - allowNull: false, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "updatedAt" - }, - fee: { - type: DataTypes.DOUBLE, - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "fee" - }, - v1: { - type: DataTypes.DOUBLE, - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "v1" - }, - v2: { - type: DataTypes.DOUBLE, - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "v2" - }, - rate: { - type: DataTypes.DOUBLE, - allowNull: true, - defaultValue: null, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "rate" - }, - text: { - type: DataTypes.TEXT, - allowNull: false, - defaultValue: false, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "text" - }, - public: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: false, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "public" - }, - accepted: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: false, - primaryKey: false, - autoIncrement: false, - comment: null, - field: "accepted" - }, -}; - -const options = { - tableName: "proposals", - comment: "", - indexes: [] -}; - -db.Proposal = db.define("proposals_model", attributes, options); -- cgit v1.2.3