aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-06-23 14:39:41 -0700
committerAdam Soltys <[email protected]>2020-06-23 14:39:41 -0700
commitd6af21064d106e6179d76e0dddee049c5e7c0fc5 (patch)
treed6cf57a7659a6e60ad80992c8f93dcc59c11c770 /db
parent3c46dc86b753cdfd71da7b8bb86710032668b5eb (diff)
downloadcoinos-server-d6af21064d106e6179d76e0dddee049c5e7c0fc5.tar.gz
coinos-server-d6af21064d106e6179d76e0dddee049c5e7c0fc5.zip
lnurl auth
Diffstat (limited to 'db')
-rw-r--r--db/index.js13
-rw-r--r--db/models/keys.js39
-rw-r--r--db/models/users.js9
-rw-r--r--db/schema.sql27
4 files changed, 83 insertions, 5 deletions
diff --git a/db/index.js b/db/index.js
index 215d34df..4142de33 100644
--- a/db/index.js
+++ b/db/index.js
@@ -5,11 +5,12 @@ db = new Sequelize(conf.database, conf.username, conf.password, {
host: conf.host,
dialect: conf.dialect,
logging: false,
- dialectOptions: { multipleStatements: true }
+ dialectOptions: conf.dialectOptions
});
require("./models/accounts.js");
require("./models/invoices.js");
+require("./models/keys.js");
require("./models/payments.js");
require("./models/users.js");
@@ -23,6 +24,11 @@ db["User"].hasMany(db["Invoice"], {
foreignKey: "user_id"
});
+db["User"].hasMany(db["Key"], {
+ as: "keys",
+ foreignKey: "user_id"
+});
+
db["User"].hasMany(db["Payment"], {
as: "payments",
foreignKey: "user_id"
@@ -43,6 +49,11 @@ db["Invoice"].belongsTo(db["User"], {
foreignKey: "user_id"
});
+db["Key"].belongsTo(db["User"], {
+ as: "user",
+ foreignKey: "user_id"
+});
+
db["Payment"].belongsTo(db["Account"], {
as: "account",
foreignKey: "account_id"
diff --git a/db/models/keys.js b/db/models/keys.js
new file mode 100644
index 00000000..1a2a84ae
--- /dev/null
+++ b/db/models/keys.js
@@ -0,0 +1,39 @@
+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"
+ },
+ hex: {
+ type: DataTypes.STRING(255),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "hex"
+ },
+};
+
+const options = {
+ tableName: "linkingkeys",
+ comment: "",
+ indexes: []
+};
+
+db["Key"] = db.define("keys_model", attributes, options);
diff --git a/db/models/users.js b/db/models/users.js
index 1c16f737..5d4f33ae 100644
--- a/db/models/users.js
+++ b/db/models/users.js
@@ -19,6 +19,15 @@ const attributes = {
comment: null,
field: "ip"
},
+ seed: {
+ type: DataTypes.STRING(255),
+ allowNull: true,
+ defaultValue: null,
+ primaryKey: false,
+ autoIncrement: false,
+ comment: null,
+ field: "seed"
+ },
username: {
type: DataTypes.STRING(255),
allowNull: true,
diff --git a/db/schema.sql b/db/schema.sql
index f5b6e187..d4b15e11 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=3720 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=3722 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -81,7 +81,24 @@ CREATE TABLE `invoices` (
`tip` double DEFAULT NULL,
`network` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=4447 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=4448 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `linkingkeys`
+--
+
+DROP TABLE IF EXISTS `linkingkeys`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `linkingkeys` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` int(11) DEFAULT NULL,
+ `hex` varchar(255) DEFAULT NULL,
+ `createdAt` datetime NOT NULL,
+ `updatedAt` datetime NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4451 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -138,9 +155,11 @@ CREATE TABLE `users` (
`otpsecret` varchar(255) DEFAULT NULL,
`ip` int(10) unsigned DEFAULT NULL,
`subscriptions` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
+ `seed` varchar(255) DEFAULT NULL,
+ `linkingKeys` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ip` (`ip`)
-) ENGINE=InnoDB AUTO_INCREMENT=624 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=626 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -152,4 +171,4 @@ CREATE TABLE `users` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2020-06-15 13:37:25
+-- Dump completed on 2020-06-23 10:58:27