aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized
diff options
context:
space:
mode:
authorRanabir Guin <[email protected]>2021-05-14 10:19:56 -0700
committerAdam Soltys <[email protected]>2021-06-09 16:05:30 -0700
commit8594c1b1482564b0e997250d2857855f39c11468 (patch)
tree9281e4fe3bbbebeef87c93a125eaeacd3d77a2c7 /db/normalized
parentb97fdafccb2b595a90b629eacff8ae9958d99737 (diff)
downloadcoinos-server-8594c1b1482564b0e997250d2857855f39c11468.tar.gz
coinos-server-8594c1b1482564b0e997250d2857855f39c11468.zip
add ln_assets; update normalized README
Diffstat (limited to 'db/normalized')
-rw-r--r--db/normalized/README.md36
-rw-r--r--db/normalized/ln_assets.js34
2 files changed, 55 insertions, 15 deletions
diff --git a/db/normalized/README.md b/db/normalized/README.md
index 30228cbb..9d02fa6e 100644
--- a/db/normalized/README.md
+++ b/db/normalized/README.md
@@ -1,16 +1,14 @@
# General guidelines for Database schema:
-- Some 1-1 tables are split up simply to separate scope or to control access permission (ie only user_preferences table may be edited by users themselves)
-
-- String fields which have a finite number of options should be changed to either:
- - an FK to a separate lookup table (when the options is large or can grow)
+- String fields whose values are NOT open-ended (ie can contain random strings) should be changed to either:
+ - an FK to a separate lookup table (when the domain of options is large or can grow)
- an enum (when there are a short list of essentailly static options)
- Field names should follow SQL standards:
- lower case
- underscore_separated_words
-- options should be standardized with:
+- options for designated models should be standardized with:
{
tableName: "table_name",
comment: "description of table if not self-evident",
@@ -18,10 +16,13 @@
createdAt: 'created_at',
updatedAt: 'updated_at',
indexes: [
- {}
+ { <as required> }
]
};
- - note createdAt, updatedAt are renamed to abide by SQL standard.
+
+ ## Note regarding field attributes specified in model:
+
+ - createdAt, updatedAt are renamed to abide by SQL standard.
- by default allowNull is false, so this attribute need only be specified when fields are NOT NULL.
@@ -29,13 +30,18 @@
- may need to add indexes to more fields for rapid access
- ## Questions:
- - Are indexes automatically generated for primary keys and/or foreign keys ?
- - Do we add non-unique indexes for data mining: eg { fields: ['username'] }
- - Do timestamp fields require default value spec (eg Sequelize.NOW) ?
+ ## Notes regarding changes / updates
+
+ - Some 1-1 tables are split up simply to separate scope or to control access permission (ie only user_preferences table may be edited by users themselves)
+
+ ## Sequelize Operational Questions:
+ - Are indexes automatically generated by Sequelize migration for primary keys and/or foreign keys ?
+ - Does Sequelize add non-unique indexes for data mining if specified: eg { fields: ['username'] }
+ - Do timestamp fields require default value spec (eg Sequelize.NOW) ... or how can we define this in model ?
- - payments table needs to be investigated
- - is invoices required or just summary information ?
- - need to add orders table
- - need to add subscriptions table if applicable (?)
+ ## Ongoing Questions:
+ - payments table needs to be investigated and refactored
+ - is invoices table required or is this just summary information ?
+ - orders table needs to be investigated and refactored
+ - need to add subscriptions table if applicable ( what is this comprised of ?)
diff --git a/db/normalized/ln_assets.js b/db/normalized/ln_assets.js
new file mode 100644
index 00000000..ae8c5883
--- /dev/null
+++ b/db/normalized/ln_assets.js
@@ -0,0 +1,34 @@
+const { DataTypes } = require('sequelize');
+
+const attributes = {
+ id: {
+ type: DataTypes.INTEGER(11),
+ primaryKey: true,
+ autoIncrement: true,
+ allowNull: false
+ },
+ name: {
+ type: DataTypes.STRING(255),
+ comment: "eg 'USD'"
+ },
+ code: {
+ type: DataTypes.INTEGER(11),
+ allowNull: false,
+ comment: "unique uuid on liquid network"
+ }
+}
+const options = {
+ tableName: "codes",
+ comment: "Reference subset of liquid network asset codes",
+ timestamps: true,
+ createdAt: 'created_at',
+ updatedAt: 'updated_at',
+ indexes: [
+ {
+ unique: true,
+ fields: ['code']
+ }
+ ]
+};
+
+db["LnAsset"] = db.define("ln_assets_model", attributes, options);