diff options
| author | Adam Soltys <[email protected]> | 2022-09-02 14:47:08 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-02 14:47:14 -0700 |
| commit | 3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (patch) | |
| tree | 16cd6c55d5dc481331b1e8b640d179f193e7ea13 /db | |
| parent | 7a8d64833de8873afb92982b3f5bfff59b30c542 (diff) | |
| download | coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.tar.gz coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.zip | |
es6 migration
Diffstat (limited to 'db')
| -rw-r--r-- | db/db.js | 17 | ||||
| -rw-r--r-- | db/index.js | 19 | ||||
| -rw-r--r-- | db/models/accounts.js | 3 | ||||
| -rw-r--r-- | db/models/codes.js | 3 | ||||
| -rw-r--r-- | db/models/deposits.js | 3 | ||||
| -rw-r--r-- | db/models/invoices.js | 3 | ||||
| -rw-r--r-- | db/models/keys.js | 3 | ||||
| -rw-r--r-- | db/models/orders.js | 3 | ||||
| -rw-r--r-- | db/models/payments.js | 3 | ||||
| -rw-r--r-- | db/models/referrals.js | 3 | ||||
| -rw-r--r-- | db/models/users.js | 3 | ||||
| -rw-r--r-- | db/models/waiting_list.js | 3 | ||||
| -rw-r--r-- | db/models/withdrawals.js | 3 | ||||
| -rw-r--r-- | db/normalized/accounts.js | 2 | ||||
| -rw-r--r-- | db/normalized/credits.js | 2 | ||||
| -rw-r--r-- | db/normalized/debits.js | 2 | ||||
| -rw-r--r-- | db/normalized/deposits.js | 2 | ||||
| -rw-r--r-- | db/normalized/exchanges.js | 2 | ||||
| -rw-r--r-- | db/normalized/invoices.js | 2 | ||||
| -rw-r--r-- | db/normalized/non_custodial_accounts.js | 2 | ||||
| -rw-r--r-- | db/normalized/transfers.js | 2 | ||||
| -rw-r--r-- | db/normalized/waiting_list.js | 2 | ||||
| -rw-r--r-- | db/normalized/withdrawals.js | 2 |
23 files changed, 53 insertions, 36 deletions
diff --git a/db/db.js b/db/db.js new file mode 100644 index 00000000..914d049f --- /dev/null +++ b/db/db.js @@ -0,0 +1,17 @@ +import Sequelize from '@sequelize/core'; +import dbOptions from '../config/knexfile.js'; + +let { database, user, password, host } = dbOptions[process.env.NODE_ENV].connection; + +export default new Sequelize( + database, + user, + password, + { + host, + dialect: "mariadb", + logging: false, + dialectOptions: { multipleStatements: true, timezone: "Etc/GMT+7" }, + } +); + diff --git a/db/index.js b/db/index.js index 0592dc7c..9f34884e 100644 --- a/db/index.js +++ b/db/index.js @@ -1,25 +1,12 @@ -import Sequelize from 'sequelize'; -import dbOptions from './../config/knexfile.js'; +import Sequelize from '@sequelize/core'; -db = new Sequelize( - dbOptions.connection.database, - dbOptions.connection.user, - dbOptions.connection.password, - { - host: dbOptions.connection.host, - dialect: "mariadb", - logging: false, - dialectOptions: { multipleStatements: true, timezone: "Etc/GMT+7" }, - } -); +import db from "./db.js"; db.authenticate().catch((err) => { console.debug("Error connecting to database: " + err.message); console.log(dbOptions.connection.database + "." + dbOptions.connection.user); }); -knex = require("knex")(dbOptions); - import './models/accounts.js'; import './models/codes.js'; import './models/deposits.js'; @@ -166,3 +153,5 @@ Payment.belongsTo(Payment, { }); db.Order = Order; + +export default db; diff --git a/db/models/accounts.js b/db/models/accounts.js index 3dd9ff71..c7e76277 100644 --- a/db/models/accounts.js +++ b/db/models/accounts.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/codes.js b/db/models/codes.js index b00f5bfb..57edfb35 100644 --- a/db/models/codes.js +++ b/db/models/codes.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { code: { diff --git a/db/models/deposits.js b/db/models/deposits.js index c52d37dd..0d030bf2 100644 --- a/db/models/deposits.js +++ b/db/models/deposits.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/invoices.js b/db/models/invoices.js index 54f3f8bd..c405b122 100644 --- a/db/models/invoices.js +++ b/db/models/invoices.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/keys.js b/db/models/keys.js index 47ec7745..8807e00e 100644 --- a/db/models/keys.js +++ b/db/models/keys.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/orders.js b/db/models/orders.js index 864b6b44..60fd539b 100644 --- a/db/models/orders.js +++ b/db/models/orders.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/payments.js b/db/models/payments.js index fd6b3593..31ce4855 100644 --- a/db/models/payments.js +++ b/db/models/payments.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/referrals.js b/db/models/referrals.js index 79c73e38..2d1e8d8c 100644 --- a/db/models/referrals.js +++ b/db/models/referrals.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/users.js b/db/models/users.js index fa89f315..50b8941c 100644 --- a/db/models/users.js +++ b/db/models/users.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/waiting_list.js b/db/models/waiting_list.js index 742306c0..76fb9e3f 100644 --- a/db/models/waiting_list.js +++ b/db/models/waiting_list.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/models/withdrawals.js b/db/models/withdrawals.js index 12f6ee6d..53863cbf 100644 --- a/db/models/withdrawals.js +++ b/db/models/withdrawals.js @@ -1,4 +1,5 @@ -import { DataTypes } from 'sequelize'; +import db from "../db.js"; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/normalized/accounts.js b/db/normalized/accounts.js index c6ab1100..8e5aad33 100644 --- a/db/normalized/accounts.js +++ b/db/normalized/accounts.js @@ -40,7 +40,7 @@ export const down = function(knex) { // -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { diff --git a/db/normalized/credits.js b/db/normalized/credits.js index 92bf5359..5511b616 100644 --- a/db/normalized/credits.js +++ b/db/normalized/credits.js @@ -42,7 +42,7 @@ return knex.schema.dropTable('credits'); // context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ? -import { DataTypes } from 'sequelize'; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/normalized/debits.js b/db/normalized/debits.js index 256853c8..6fcee974 100644 --- a/db/normalized/debits.js +++ b/db/normalized/debits.js @@ -42,7 +42,7 @@ return knex.schema.dropTable('debits'); // context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ? -import { DataTypes } from 'sequelize'; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/normalized/deposits.js b/db/normalized/deposits.js index 2a3c83fb..17a7c500 100644 --- a/db/normalized/deposits.js +++ b/db/normalized/deposits.js @@ -23,7 +23,7 @@ export const down = function(knex) { // code -> confirmation_code -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { diff --git a/db/normalized/exchanges.js b/db/normalized/exchanges.js index 2f34a394..2be91990 100644 --- a/db/normalized/exchanges.js +++ b/db/normalized/exchanges.js @@ -38,7 +38,7 @@ return knex.schema.dropTable('exchanges'); // context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ? -import { DataTypes } from 'sequelize'; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/normalized/invoices.js b/db/normalized/invoices.js index 25f5b681..823ad11d 100644 --- a/db/normalized/invoices.js +++ b/db/normalized/invoices.js @@ -39,7 +39,7 @@ export const down = function(knex) { // checkout - fields ? // voucher - fields ? -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { diff --git a/db/normalized/non_custodial_accounts.js b/db/normalized/non_custodial_accounts.js index 5c56b966..e8190ce6 100644 --- a/db/normalized/non_custodial_accounts.js +++ b/db/normalized/non_custodial_accounts.js @@ -20,7 +20,7 @@ export const down = function(knex) { return knex.schema.dropTable('non_custodial_accounts'); }; -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { diff --git a/db/normalized/transfers.js b/db/normalized/transfers.js index aa81472f..64f5c392 100644 --- a/db/normalized/transfers.js +++ b/db/normalized/transfers.js @@ -49,7 +49,7 @@ return knex.schema.dropTable('transfers'); // context for path, memo, rate, preimage, address, received, fee, tip, confirmed, redeemcode ? -import { DataTypes } from 'sequelize'; +import { DataTypes } from '@sequelize/core'; const attributes = { id: { diff --git a/db/normalized/waiting_list.js b/db/normalized/waiting_list.js index f6908868..5a37dc52 100644 --- a/db/normalized/waiting_list.js +++ b/db/normalized/waiting_list.js @@ -14,7 +14,7 @@ export const down = function(knex) { return knex.schema.dropTable('waiting_list'); }; -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { diff --git a/db/normalized/withdrawals.js b/db/normalized/withdrawals.js index d404e6e3..742f3dbf 100644 --- a/db/normalized/withdrawals.js +++ b/db/normalized/withdrawals.js @@ -24,7 +24,7 @@ export const down = function(knex) { // // bank info -> bank_account records -// const { DataTypes } = require('sequelize'); +// const { DataTypes } = require('@sequelize/core'); // const attributes = { // id: { |
