aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-07-20 21:16:16 -0700
committerAdam Soltys <[email protected]>2020-07-20 21:16:16 -0700
commit5a15eb109b6ddd8232abfecaafc7d8ba7ada14ab (patch)
tree04575adc8c837413bb9c743cfb2234ec95d76bbb /db
parent1bbf30a5ece3b361ac5eb00da052fa63cbc91a2e (diff)
downloadcoinos-server-5a15eb109b6ddd8232abfecaafc7d8ba7ada14ab.tar.gz
coinos-server-5a15eb109b6ddd8232abfecaafc7d8ba7ada14ab.zip
atomic swaps
Diffstat (limited to 'db')
-rw-r--r--db/index.js6
-rw-r--r--db/models/proposals.js102
-rw-r--r--db/schema.sql34
3 files changed, 136 insertions, 6 deletions
diff --git a/db/index.js b/db/index.js
index 1b4cc0e4..7f011c9c 100644
--- a/db/index.js
+++ b/db/index.js
@@ -13,6 +13,7 @@ require("./models/codes.js");
require("./models/invoices.js");
require("./models/keys.js");
require("./models/payments.js");
+require("./models/proposals.js");
require("./models/users.js");
db["User"].hasMany(db["Account"], {
@@ -64,3 +65,8 @@ db["Payment"].belongsTo(db["User"], {
as: "user",
foreignKey: "user_id"
});
+
+db["Proposal"].belongsTo(db["User"], {
+ as: "user",
+ foreignKey: "user_id"
+});
diff --git a/db/models/proposals.js b/db/models/proposals.js
new file mode 100644
index 00000000..350bdab8
--- /dev/null
+++ b/db/models/proposals.js
@@ -0,0 +1,102 @@
+const { DataTypes } = require('sequelize');
+
+const attributes = {
+ id: {
+ type: DataTypes.INTEGER(11),
+ allowNull: false,
+ defaultValue: null,
+ primaryKey: true,
+ autoIncrement: true,
+ comment: null,
+ field: "id"
+ },
+ user_id: {
+ type: DataTypes.INTEGER(11),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "user_id"
+ },
+ 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"
+ },
+ a1: {
+ type: DataTypes.STRING(255),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "a1"
+ },
+ a2: {
+ type: DataTypes.STRING(255),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "a2"
+ },
+ v1: {
+ type: DataTypes.INTEGER,
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "v1"
+ },
+ v2: {
+ type: DataTypes.INTEGER,
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "v2"
+ },
+ text: {
+ type: DataTypes.TEXT,
+ allowNull: false,
+ defaultValue: false,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "text"
+ },
+ 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);
diff --git a/db/schema.sql b/db/schema.sql
index 940a3490..ff272a43 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -57,7 +57,7 @@ CREATE TABLE `accounts` (
`ticker` varchar(255) DEFAULT NULL,
`precision` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3730 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=3731 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -98,7 +98,7 @@ CREATE TABLE `invoices` (
`uuid` varchar(255) DEFAULT NULL,
`memo` text DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=4626 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=4644 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -115,7 +115,7 @@ CREATE TABLE `linkingkeys` (
`createdAt` datetime NOT NULL,
`updatedAt` datetime NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=4495 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=4497 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -144,7 +144,29 @@ CREATE TABLE `payments` (
`preimage` varchar(255) DEFAULT NULL,
`memo` text DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=4458 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=4459 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `proposals`
+--
+
+DROP TABLE IF EXISTS `proposals`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `proposals` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `a1` varchar(255) DEFAULT NULL,
+ `a2` varchar(255) DEFAULT NULL,
+ `v1` int(11) DEFAULT NULL,
+ `v2` int(11) DEFAULT NULL,
+ `user_id` int(11) DEFAULT NULL,
+ `createdAt` datetime NOT NULL,
+ `updatedAt` datetime NOT NULL,
+ `accepted` tinyint(1) NOT NULL DEFAULT 0,
+ `text` text DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -192,7 +214,7 @@ CREATE TABLE `users` (
`fiat` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `ip` (`ip`)
-) ENGINE=InnoDB AUTO_INCREMENT=633 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=634 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -204,4 +226,4 @@ CREATE TABLE `users` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2020-07-17 20:55:55
+-- Dump completed on 2020-07-20 21:16:00