aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized
diff options
context:
space:
mode:
Diffstat (limited to 'db/normalized')
-rw-r--r--db/normalized/README.md48
-rw-r--r--db/normalized/accounts.js231
-rw-r--r--db/normalized/bank_accounts.js24
-rw-r--r--db/normalized/credits.js236
-rw-r--r--db/normalized/debits.js236
-rw-r--r--db/normalized/deposits.js100
-rw-r--r--db/normalized/exchanges.js232
-rw-r--r--db/normalized/invoices.js206
-rw-r--r--db/normalized/liquid_assets.js21
-rw-r--r--db/normalized/ln_keys.js16
-rw-r--r--db/normalized/lnurl_codes.js14
-rw-r--r--db/normalized/non_custodial_accounts.js91
-rw-r--r--db/normalized/orders.js29
-rw-r--r--db/normalized/referrals.js20
-rw-r--r--db/normalized/transactions.js41
-rw-r--r--db/normalized/transfers.js243
-rw-r--r--db/normalized/user_preferences.js20
-rw-r--r--db/normalized/user_security.js22
-rw-r--r--db/normalized/users.js18
-rw-r--r--db/normalized/vouchers.js18
-rw-r--r--db/normalized/waiting_list.js60
-rw-r--r--db/normalized/withdrawals.js128
22 files changed, 0 insertions, 2054 deletions
diff --git a/db/normalized/README.md b/db/normalized/README.md
deleted file mode 100644
index fd3cb0d3..00000000
--- a/db/normalized/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# General guidelines for Database schema:
-
-- 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 for designated models should be standardized with:
- {
- tableName: "table_name",
- comment: "description of table if not self-evident",
- timestamps: true,
- createdAt: 'created_at',
- updatedAt: 'updated_at',
- indexes: [
- { <as required> }
- ]
- };
-
- ## 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.
-
- - comment attribute should added to any field that is not self-evident
-
- - may need to add indexes to more fields for rapid access
-
- ## 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 ?
-
- ## 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 ?)
- - user_keys table should be commented to clarify application of each of these values.
-
diff --git a/db/normalized/accounts.js b/db/normalized/accounts.js
deleted file mode 100644
index 8e5aad33..00000000
--- a/db/normalized/accounts.js
+++ /dev/null
@@ -1,231 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('accounts', function(t) {
- t.increments('id').unsigned().primary();
- t.int('user_id').notNull();
- t.foreign('user_id').references('users.id');
-
- t.int('uuid').notNull();
-
- t.double('balance');
- t.double('pending');
-
- t.enu('network', ['Bitcoin', 'Liquid', 'Lightning', 'CoinOS']).notNull();
-
- t.longtext('contract').collate('utf8mb4').nullable(); // custodial ?
-
- // knex.raw("ALTER TABLE accounts MODIFY `contract` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL")
-
- // t.string('hide');
- // t.string('index');
-
- t.int('liquid_asset_id').notNull();
- t.foreign('liquid_asset_id').references('liquid_assets.id');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('accounts');
-};
-
-// Change
-//
-// move assets fields (asset, ticker, name, precision...) to separate liquid_assets reference
-
-// separate network specific fields to bitcoin_accounts / liquid_accounts / coinos_accounts tables ? or just non_custodial ?
-// eg liquid -> liquid_asset info
-// non-custodial ? -> privkey, pubkey, path, seed ?
-// contract, hide, index ?
-//
-
-
-// const { DataTypes } = require('@sequelize/core');
-
-// 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"
-// },
-// path: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "path"
-// },
-// seed: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "seed"
-// },
-// network: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "network"
-// },
-// name: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "name"
-// },
-// contract: {
-// type: DataTypes.TEXT,
-// get: function() {
-// return JSON.parse(this.getDataValue("contract"));
-// },
-// set: function(value) {
-// return this.setDataValue("contract", JSON.stringify(value));
-// },
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "contract"
-// },
-// domain: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "domain"
-// },
-// ticker: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "ticker"
-// },
-// asset: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "asset"
-// },
-// balance: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "balance"
-// },
-// pending: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "pending"
-// },
-// hide: {
-// type: DataTypes.BOOLEAN,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "hide"
-// },
-// index: {
-// type: DataTypes.INTEGER(11),
-// allowNull: false,
-// defaultValue: 0,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "index"
-// },
-// privkey: {
-// type: DataTypes.STRING,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "privkey"
-// },
-// pubkey: {
-// type: DataTypes.STRING,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "pubkey"
-// },
-// precision: {
-// type: DataTypes.INTEGER(11),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "precision"
-// },
-// };
-
-// const options = {
-// tableName: "accounts",
-// comment: "",
-// indexes: []
-// };
-
-// db["Account"] = db.define("accounts_model", attributes, options);
diff --git a/db/normalized/bank_accounts.js b/db/normalized/bank_accounts.js
deleted file mode 100644
index 5d8ea0dc..00000000
--- a/db/normalized/bank_accounts.js
+++ /dev/null
@@ -1,24 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('bank_accounts', function(t) {
- t.increments('id').unsigned().primary();
- t.int('user_id').notNull();
- t.foreign('user_id').references('users.id');
-
- t.int('transit_number');
- t.int('institution_number');
- t.int('account_number');
-
- t.string('swift');
- t.string('iban');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('user_security');
-};
-
-// Changes:
-//
-// bank info -> bank_account records
diff --git a/db/normalized/credits.js b/db/normalized/credits.js
deleted file mode 100644
index 5511b616..00000000
--- a/db/normalized/credits.js
+++ /dev/null
@@ -1,236 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('credits', function(t) {
- t.increments('id').unsigned().primary();
-
- t.enu('type', ['deposit', 'order', 'transfer', 'invoice', 'exchange'])
- t.string('description')
-
- t.int('account_id').notNull();
- t.foreign('account_id').references('accounts.id');
-
- t.double('amount');
-
- t.enu('status', ['pending', 'completed', 'reversed', 'cancelled'])
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('credits');
-};
-
-// Changes:
-//
-// Should these be tracked as transactions ?
-// SAT -> SAT
-// tracking various exchange variations (outside of external networks ?)
-//
-// Is user / account / amount info redundant ?
-// + transaction_type: deposit / withdrawal / transfer / exchange ?
-//
-// add transfers table ? (for internal transfers only ?)
-// add redemptions table ? (for bitcoin transfers only ?)
-// add exchanges table ? (for conversion from one currency to another)
-//
-// network -> scope: internal / bitcoin / liquid / lightning ?
-// add bitcoin_transaction ? (with redemption attributes)
-// add liquid_transaction ? ()
-// add lightning_transaction ? (with LN_invoice_hash)
-// add internal_transaction ? ()
-//
-// context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ?
-
-
-import { DataTypes } from '@sequelize/core';
-
-const attributes = {
- id: {
- type: DataTypes.INTEGER(11),
- allowNull: false,
- defaultValue: null,
- primaryKey: true,
- autoIncrement: true,
- comment: null,
- field: "id"
- },
- account_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "account_id"
- },
- user_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "user_id"
- },
- path: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "path"
- },
- memo: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "memo"
- },
- hash: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "hash"
- },
- 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"
- },
- rate: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "rate"
- },
- preimage: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "preimage"
- },
- network: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "network"
- },
- currency: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "currency"
- },
- address: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "address"
- },
- received: {
- type: DataTypes.INTEGER(1),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "received"
- },
- amount: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "amount"
- },
- fee: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "fee"
- },
- tip: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "tip"
- },
- redeemed: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemed"
- },
- redeemcode: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemcode"
- },
- confirmed: {
- type: DataTypes.INTEGER(1),
- allowNull: false,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "confirmed"
- }
-};
-
-const options = {
- tableName: "payments",
- comment: "",
- indexes: []
-};
-
-db["Payment"] = db.define("payments_model", attributes, options);
diff --git a/db/normalized/debits.js b/db/normalized/debits.js
deleted file mode 100644
index 6fcee974..00000000
--- a/db/normalized/debits.js
+++ /dev/null
@@ -1,236 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('debits', function(t) {
- t.increments('id').unsigned().primary();
-
- t.enu('type', ['withdrawal', 'order', 'transfer', 'invoice', 'exchange'])
-
- t.int('account_id').notNull();
- t.foreign('account_id').references('accounts.id');
-
- t.double('amount');
-
- t.enu('type', ['withdrawal', 'transfer', 'order', 'invoice'])
- t.enu('status', ['pending', 'completed', 'reversed', 'cancelled'])
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('debits');
-};
-
-// Changes:
-//
-// Should these be tracked as transactions ?
-// SAT -> SAT
-// tracking various exchange variations (outside of external networks ?)
-//
-// Is user / account / amount info redundant ?
-// + transaction_type: deposit / withdrawal / transfer / exchange ?
-//
-// add transfers table ? (for internal transfers only ?)
-// add redemptions table ? (for bitcoin transfers only ?)
-// add exchanges table ? (for conversion from one currency to another)
-//
-// network -> scope: internal / bitcoin / liquid / lightning ?
-// add bitcoin_transaction ? (with redemption attributes)
-// add liquid_transaction ? ()
-// add lightning_transaction ? (with LN_invoice_hash)
-// add internal_transaction ? ()
-//
-// context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ?
-
-
-import { DataTypes } from '@sequelize/core';
-
-const attributes = {
- id: {
- type: DataTypes.INTEGER(11),
- allowNull: false,
- defaultValue: null,
- primaryKey: true,
- autoIncrement: true,
- comment: null,
- field: "id"
- },
- account_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "account_id"
- },
- user_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "user_id"
- },
- path: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "path"
- },
- memo: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "memo"
- },
- hash: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "hash"
- },
- 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"
- },
- rate: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "rate"
- },
- preimage: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "preimage"
- },
- network: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "network"
- },
- currency: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "currency"
- },
- address: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "address"
- },
- received: {
- type: DataTypes.INTEGER(1),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "received"
- },
- amount: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "amount"
- },
- fee: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "fee"
- },
- tip: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "tip"
- },
- redeemed: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemed"
- },
- redeemcode: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemcode"
- },
- confirmed: {
- type: DataTypes.INTEGER(1),
- allowNull: false,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "confirmed"
- }
-};
-
-const options = {
- tableName: "payments",
- comment: "",
- indexes: []
-};
-
-db["Payment"] = db.define("payments_model", attributes, options);
diff --git a/db/normalized/deposits.js b/db/normalized/deposits.js
deleted file mode 100644
index 17a7c500..00000000
--- a/db/normalized/deposits.js
+++ /dev/null
@@ -1,100 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('deposits', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('credit_id').notNull();
- t.foreign('credit_id').references('credits.id');
-
- t.string('confirmation_code');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('deposits');
-};
-
-// Changes:
-//
-// reference transaction
-// reference account rather than user
-// credited - redundant with confirmation_code ?
-// code -> confirmation_code
-
-
-// const { DataTypes } = require('@sequelize/core');
-
-// const attributes = {
-// id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: false,
-// defaultValue: null,
-// primaryKey: true,
-// autoIncrement: true,
-// comment: null,
-// field: "id"
-// },
-// amount: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "amount"
-// },
-// 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"
-// },
-// credited: {
-// type: DataTypes.BOOLEAN,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "credited"
-// },
-// code: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "code"
-// },
-// };
-
-// const options = {
-// tableName: "deposits",
-// comment: "",
-// indexes: []
-// };
-
-// db["Deposit"] = db.define("deposits_model", attributes, options);
diff --git a/db/normalized/exchanges.js b/db/normalized/exchanges.js
deleted file mode 100644
index 2be91990..00000000
--- a/db/normalized/exchanges.js
+++ /dev/null
@@ -1,232 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('exchanges', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('transfer_id').notNull();
- t.foreign('transfer_id').references('transfers.id');
-
- t.double('exchange_rate').notNull()
- t.double('exchange_fee').notNull().defaultTo(0)
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('exchanges');
-};
-
-// Changes:
-//
-// Should these be tracked as transactions ?
-// SAT -> SAT
-// tracking various exchange variations (outside of external networks ?)
-//
-// Is user / account / amount info redundant ?
-// + transaction_type: deposit / withdrawal / transfer / exchange ?
-//
-// add transfers table ? (for internal transfers only ?)
-// add redemptions table ? (for bitcoin transfers only ?)
-// add exchanges table ? (for conversion from one currency to another)
-//
-// network -> scope: internal / bitcoin / liquid / lightning ?
-// add bitcoin_transaction ? (with redemption attributes)
-// add liquid_transaction ? ()
-// add lightning_transaction ? (with LN_invoice_hash)
-// add internal_transaction ? ()
-//
-// context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ?
-
-
-import { DataTypes } from '@sequelize/core';
-
-const attributes = {
- id: {
- type: DataTypes.INTEGER(11),
- allowNull: false,
- defaultValue: null,
- primaryKey: true,
- autoIncrement: true,
- comment: null,
- field: "id"
- },
- account_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "account_id"
- },
- user_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "user_id"
- },
- path: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "path"
- },
- memo: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "memo"
- },
- hash: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "hash"
- },
- 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"
- },
- rate: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "rate"
- },
- preimage: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "preimage"
- },
- network: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "network"
- },
- currency: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "currency"
- },
- address: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "address"
- },
- received: {
- type: DataTypes.INTEGER(1),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "received"
- },
- amount: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "amount"
- },
- fee: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "fee"
- },
- tip: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "tip"
- },
- redeemed: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemed"
- },
- redeemcode: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemcode"
- },
- confirmed: {
- type: DataTypes.INTEGER(1),
- allowNull: false,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "confirmed"
- }
-};
-
-const options = {
- tableName: "payments",
- comment: "",
- indexes: []
-};
-
-db["Payment"] = db.define("payments_model", attributes, options);
diff --git a/db/normalized/invoices.js b/db/normalized/invoices.js
deleted file mode 100644
index 823ad11d..00000000
--- a/db/normalized/invoices.js
+++ /dev/null
@@ -1,206 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('invoices', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('transfer_id').notNull();
- t.foreign('transfer_id').references('transfers.id');
-
- t.enu('network', ['Bitcoin', 'Liquid', 'Lightning', 'CoinOS']).notNull();
-
- t.string('bolt11'); // was 'text'
-
- // Clarify ??? - break out ? - context ? include everything encoded in hash...
- t.double('amount');
-
- // Exchanges
- // ( are there a couple of types of invoices ? - eg checkout / voucher / receive ... with different attributes ?)
- t.double('rate')
- t.string('currency')
- t.double('tip')
-
- t.string('path')
- t.string('uuid')
- t.string('memo')
- t.string('unconfidential')
- t.string('address')
- t.string('received')
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('invoices');
-};
-
-
-// Variations: ?
-// wallet -> receive - fields ?
-// checkout - fields ?
-// voucher - fields ?
-
-// const { DataTypes } = require('@sequelize/core');
-
-// const attributes = {
-// id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: false,
-// defaultValue: null,
-// primaryKey: true,
-// autoIncrement: true,
-// comment: null,
-// field: "id"
-// },
-// account_id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "account_id"
-// },
-// user_id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "user_id"
-// },
-// text: {
-// type: DataTypes.TEXT,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "text"
-// },
-// 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"
-// },
-// path: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "path"
-// },
-// rate: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "rate"
-// },
-// uuid: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "uuid"
-// },
-// memo: {
-// type: DataTypes.TEXT,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "memo"
-// },
-// network: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "network"
-// },
-// currency: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "currency"
-// },
-// unconfidential: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "unconfidential"
-// },
-// address: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "address"
-// },
-// received: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "received"
-// },
-// amount: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "amount"
-// },
-// tip: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "tip"
-// },
-// };
-
-// const options = {
-// tableName: "invoices",
-// comment: "",
-// indexes: []
-// };
-
-// db["Invoice"] = db.define("invoices_model", attributes, options);
diff --git a/db/normalized/liquid_assets.js b/db/normalized/liquid_assets.js
deleted file mode 100644
index fab96dc5..00000000
--- a/db/normalized/liquid_assets.js
+++ /dev/null
@@ -1,21 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('liquid_assets', function(t) {
- t.increments('id').unsigned().primary();
-
- t.string('asset_id').notNull();
- t.string('name').notNull();
-
- t.string('domain')
- t.string('ticker').notNull();
- t.int('precision').defaultTo(8);
- t.string('issuer_pubkey')
-
- t.boolean('registered').defaultTo(false);
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('liquid_assets');
-}; \ No newline at end of file
diff --git a/db/normalized/ln_keys.js b/db/normalized/ln_keys.js
deleted file mode 100644
index 7922e40e..00000000
--- a/db/normalized/ln_keys.js
+++ /dev/null
@@ -1,16 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('ln_keys', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('user_id').notNull();
- t.foreign('user_id').references('users.id');
-
- t.string('hex').notNull();
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('ln_keys');
-}; \ No newline at end of file
diff --git a/db/normalized/lnurl_codes.js b/db/normalized/lnurl_codes.js
deleted file mode 100644
index 5ed81135..00000000
--- a/db/normalized/lnurl_codes.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('lnurl_codes', function(t) {
- t.increments('id').unsigned().primary();
-
- t.string('code').notNull();
- t.text('text');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('lnurl_codes');
-};
diff --git a/db/normalized/non_custodial_accounts.js b/db/normalized/non_custodial_accounts.js
deleted file mode 100644
index e8190ce6..00000000
--- a/db/normalized/non_custodial_accounts.js
+++ /dev/null
@@ -1,91 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('non_custodial_accounts', function(t) {
- t.increments('id').unsigned().primary();
- t.int('account_id').notNull();
- t.foreign('account_id').references('accounts.id');
-
- // what is the scope / context of these attributes ?
- t.string('path');
- t.string('seed');
- // t.string('hide');
- // t.string('index');
- t.string('pub_key');
- t.string('priv_key');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('non_custodial_accounts');
-};
-
-// const { DataTypes } = require('@sequelize/core');
-
-// const attributes = {
-// id: {
-// type: DataTypes.INTEGER(11),
-// primaryKey: true,
-// autoIncrement: true,
-// allowNull: false
-// },
-// account_id: {
-// type: DataTypes.INTEGER(11),
-// references: { model: Account, key: 'id' },
-// allowNull: false,
-// comment: "Reference to account"
-// },
-// path: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// seed: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// network: {
-// type: DataTypes.INTEGER(11),
-// references: { model: Network, key: 'id' },
-// allowNull: false,
-// comment: "Reference to network"
-// },
-// domain: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ? ... is it unique or an enum ?"
-// },
-// ticker: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// hide: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// index: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// pub_key: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// },
-// priv_key: {
-// type: DataTypes.STRING(255),
-// comment: "What is this ?"
-// }
-// }
-// const options = {
-// tableName: "non_custodial_accounts",
-// comment: "",
-// timestamps: true,
-// createdAt: 'created_at',
-// updatedAt: 'updated_at',
-// indexes: [
-// {
-// unique: true,
-// fields: ['account_id']
-// }
-// ]
-// };
-
-// db["NonCustodialAccount"] = db.define("non_custodial_accounts_model", attributes, options);
diff --git a/db/normalized/orders.js b/db/normalized/orders.js
deleted file mode 100644
index 06e83db1..00000000
--- a/db/normalized/orders.js
+++ /dev/null
@@ -1,29 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('orders', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('sell_transfer_id').notNull();
- t.foreign('sell_transfer_id').references('transfers.id');
-
- t.int('buy_transfer_id').notNull();
- t.foreign('buy_transfer_id').references('transfers.id');
-
- // t.int('exchange_id').notNull();
- // t.foreign('exchange_id').references('exchanges.id');
-
- t.double('exchange_rate').notNull();
- // t.double('amount').notNull();
-
- t.enu('status', ['Submitted', 'Accepted', 'Cancelled']).notNull();
- t.date('completion_date')
-
- t.timestamps();
- })
-};
-
-// Bid / Accepted ... separate into Bid (credit + debit), Accepted (credit + debit)
-
-export const down = function(knex) {
- return knex.schema.dropTable('orders');
-};
-
diff --git a/db/normalized/referrals.js b/db/normalized/referrals.js
deleted file mode 100644
index 7380f2cf..00000000
--- a/db/normalized/referrals.js
+++ /dev/null
@@ -1,20 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('referrals', function(t) {
- t.increments('id').unsigned().primary();
- t.int('user_id').nullable();
- t.foreign('user_id').references('users.id');
-
- t.int('sponsor_id').notNull();
- t.foreign('sponsor_id').references('users.id');
-
- t.string('token').notNull();
- t.string('expiry').nullable();
- t.enum('status', ['available', 'used', 'expired', 'cancelled']).notNull().defaultTo('available');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('referrals');
-};
diff --git a/db/normalized/transactions.js b/db/normalized/transactions.js
deleted file mode 100644
index 230faca4..00000000
--- a/db/normalized/transactions.js
+++ /dev/null
@@ -1,41 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('transactions', function(t) {
- t.increments('id').unsigned().primary();
-
- t.enu('type', ['deposit', 'withdrawal', 'transfer', 'exchange', 'invoice', 'voucher', 'new asset'])
-
- // t.text('notes');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('transactions');
-};
-
-// Changes:
-//
-// Deposit = deposit + credit
-// Withdrawal = withdrawal + debit
-// Transfer = credit + debit
-// Exchange = credit + debit + debit + credit
-// Invoice = invoice + debit ?
-// Voucher = invoice + debit ?
-// New Asset = liquid_asset + credit
-
-//
-// context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ?
-export const up = function(knex) {
- return knex.schema.createTable('transactions', function(t) {
- t.increments('id').unsigned().primary();
-
- t.enu('type', ['deposit', 'withdrawal', 'order', 'transfer', 'invoice', 'voucher'])
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('transactions');
-}; \ No newline at end of file
diff --git a/db/normalized/transfers.js b/db/normalized/transfers.js
deleted file mode 100644
index 64f5c392..00000000
--- a/db/normalized/transfers.js
+++ /dev/null
@@ -1,243 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('transfers', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('transaction_id').notNull();
- t.foreign('transaction_id').references('accounts.id');
-
- t.int('debit_id').notNull();
- t.foreign('debit_id').references('debits.id');
-
- t.int('credit_id').notNull();
- t.foreign('credit_id').references('credits.id');
-
- // t.int('liquid_asset_id').notNull();
- // t.foreign('liquid_asset_id').references('liquid_assets.id');
-
- // t.double('amount');
- t.double('transfer_fee').notNull().defaultTo(0)
-
- t.enu('status', ['pending', 'completed', 'reversed', 'cancelled'])
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
-return knex.schema.dropTable('transfers');
-};
-
-// Changes:
-//
-// Should these be tracked as transactions ?
-// SAT -> SAT
-// tracking various exchange variations (outside of external networks ?)
-//
-// Is user / account / amount info redundant ?
-// + transaction_type: deposit / withdrawal / transfer / exchange ?
-//
-// add transfers table ? (for internal transfers only ?)
-// add redemptions table ? (for bitcoin transfers only ?)
-// add exchanges table ? (for conversion from one currency to another)
-//
-// network -> scope: internal / bitcoin / liquid / lightning ?
-// add bitcoin_transaction ? (with redemption attributes)
-// add liquid_transaction ? ()
-// add lightning_transaction ? (with LN_invoice_hash)
-// add internal_transaction ? ()
-//
-// context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ?
-
-
-import { DataTypes } from '@sequelize/core';
-
-const attributes = {
- id: {
- type: DataTypes.INTEGER(11),
- allowNull: false,
- defaultValue: null,
- primaryKey: true,
- autoIncrement: true,
- comment: null,
- field: "id"
- },
- account_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "account_id"
- },
- user_id: {
- type: DataTypes.INTEGER(11),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "user_id"
- },
- path: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "path"
- },
- memo: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "memo"
- },
- hash: {
- type: DataTypes.TEXT,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "hash"
- },
- 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"
- },
- rate: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "rate"
- },
- preimage: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "preimage"
- },
- network: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "network"
- },
- currency: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "currency"
- },
- address: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "address"
- },
- received: {
- type: DataTypes.INTEGER(1),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "received"
- },
- amount: {
- type: DataTypes.DOUBLE,
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "amount"
- },
- fee: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "fee"
- },
- tip: {
- type: DataTypes.DOUBLE,
- allowNull: false,
- defaultValue: 0,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "tip"
- },
- redeemed: {
- type: DataTypes.BOOLEAN,
- allowNull: false,
- defaultValue: false,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemed"
- },
- redeemcode: {
- type: DataTypes.STRING(255),
- allowNull: true,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "redeemcode"
- },
- confirmed: {
- type: DataTypes.INTEGER(1),
- allowNull: false,
- defaultValue: null,
- primaryKey: false,
- autoIncrement: false,
- comment: null,
- field: "confirmed"
- }
-};
-
-const options = {
- tableName: "payments",
- comment: "",
- indexes: []
-};
-
-db["Payment"] = db.define("payments_model", attributes, options);
diff --git a/db/normalized/user_preferences.js b/db/normalized/user_preferences.js
deleted file mode 100644
index 6af69f3f..00000000
--- a/db/normalized/user_preferences.js
+++ /dev/null
@@ -1,20 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('user_preferences', function(t) {
- t.increments('id').unsigned().primary();
- t.int('user_id').notNull();
- t.foreign('user_id').references('users.id');
-
- t.enum('default_unit', ['SAT', 'BTC', 'CAD']).notNull().defaultTo('SAT');
- t.enum('default_currency', ['CAD', 'USD']).notNull().defaultTo('CAD');
- t.enum('default_fiat', ['CAD', 'USD']).notNull().defaultTo('CAD');
- t.set('show_currencies', ['CAD', 'USD']).notNull().defaultTo('CAD');
- t.longtext(`subscriptions`).collate('utf8mb4').nullable(); // CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL")
- t.timestamps();
-
- // knex.raw("ALTER TABLE users MODIFY `subscriptions` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL")
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('user_preferences');
-};
diff --git a/db/normalized/user_security.js b/db/normalized/user_security.js
deleted file mode 100644
index 919b2902..00000000
--- a/db/normalized/user_security.js
+++ /dev/null
@@ -1,22 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('user_security', function(t) {
- t.increments('id').unsigned().primary();
- t.int('user_id').notNull();
- t.foreign('user_id').references('users.id');
-
- t.boolean('twofa').notNull().defaultTo(false);
- t.string('pin').notNull();
- t.string('otp_secret').nullable();
- t.string('seed').nullable();
-
- t.boolean('email_verified').notNull().default(false)
- t.boolean('phone_verified').notNull().default(false)
- t.boolean('kyc_verified').notNull().default(false)
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('user_security');
-}; \ No newline at end of file
diff --git a/db/normalized/users.js b/db/normalized/users.js
deleted file mode 100644
index dd239f24..00000000
--- a/db/normalized/users.js
+++ /dev/null
@@ -1,18 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('users', function(t) {
- t.increments('id').unsigned().primary();
-
- 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');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('users');
-}; \ No newline at end of file
diff --git a/db/normalized/vouchers.js b/db/normalized/vouchers.js
deleted file mode 100644
index 35d54de2..00000000
--- a/db/normalized/vouchers.js
+++ /dev/null
@@ -1,18 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('vouchers', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('invoice_id').notNull();
- t.foreign('invoice_id').references('invoices.id');
-
- t.string('redemption_code').notNull();
-
- t.enu('status', ['pending', 'redeemed', 'cancelled']).notNull();
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('vouchers');
-}; \ No newline at end of file
diff --git a/db/normalized/waiting_list.js b/db/normalized/waiting_list.js
deleted file mode 100644
index 5a37dc52..00000000
--- a/db/normalized/waiting_list.js
+++ /dev/null
@@ -1,60 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('waiting_list', function(t) {
- t.increments('id').unsigned().primary();
-
- t.string('email').notNull();
- t.string('phone').notNull();
- t.enu('status', ['pending', 'activated', 'expired', 'cancelled']).notNull();
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('waiting_list');
-};
-
-// const { DataTypes } = require('@sequelize/core');
-
-// const attributes = {
-// id: {
-// type: DataTypes.INTEGER(11),
-// primaryKey: true,
-// autoIncrement: true,
-// allowNull: false
-// },
-// 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
-// }
-// },
-// status: {
-// type: DataTypes.ENUM,
-// values: ['pending', 'activated', 'expired', 'cancelled'],
-// defaultValue: 'pending',
-// allowNull: false
-// }
-// }
-
-// const options = {
-// tableName: "waiting_list",
-// comment: "Users on waiting list",
-// timestamps: true,
-// createdAt: 'created_at',
-// updatedAt: 'updated_at',
-// indexes: [
-// {
-// unique: true,
-// fields: ['email', 'sms']
-// }
-// ]
-// };
-
-// db["WaitingList"] = db.define("waiting_list_model", attributes, options);
diff --git a/db/normalized/withdrawals.js b/db/normalized/withdrawals.js
deleted file mode 100644
index 742f3dbf..00000000
--- a/db/normalized/withdrawals.js
+++ /dev/null
@@ -1,128 +0,0 @@
-export const up = function(knex) {
- return knex.schema.createTable('withdrawals', function(t) {
- t.increments('id').unsigned().primary();
-
- t.int('debit_id').notNull();
- t.foreign('debit_id').references('debits.id');
-
- t.int('bank_account_id').notNull();
- t.foreign('bank_account_id').references('bank_accounts.id');
-
- t.double('withdrawal_fee').notNull().defaultTo(0)
-
- t.text('notes');
-
- t.timestamps();
- })
-};
-
-export const down = function(knex) {
- return knex.schema.dropTable('withdrawals');
-};
-
-// Changes:
-//
-// bank info -> bank_account records
-
-// const { DataTypes } = require('@sequelize/core');
-
-// const attributes = {
-// id: {
-// type: DataTypes.INTEGER(11),
-// allowNull: false,
-// defaultValue: null,
-// primaryKey: true,
-// autoIncrement: true,
-// comment: null,
-// field: "id"
-// },
-// amount: {
-// type: DataTypes.DOUBLE,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "amount"
-// },
-// 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"
-// },
-// transit: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "transit"
-// },
-// institution: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "institution"
-// },
-// account: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "account"
-// },
-// email: {
-// type: DataTypes.STRING(255),
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "email"
-// },
-// notes: {
-// type: DataTypes.TEXT,
-// allowNull: true,
-// defaultValue: null,
-// primaryKey: false,
-// autoIncrement: false,
-// comment: null,
-// field: "notes"
-// },
-// };
-
-// const options = {
-// tableName: "withdrawals",
-// comment: "",
-// indexes: []
-// };
-
-// db["Withdrawal"] = db.define("withdrawals_model", attributes, options);