diff options
| author | Adam Soltys <[email protected]> | 2023-01-08 21:05:34 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-08 21:05:34 -0800 |
| commit | dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7 (patch) | |
| tree | 6c6b8930ebe9c2cc5b8d1f759e61260f509fdd7a /db/migrations | |
| parent | f7b844883506a8072213245b9b8a2b988694e4f5 (diff) | |
| download | coinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.tar.gz coinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.zip | |
tech debt jubilee
Diffstat (limited to 'db/migrations')
| -rw-r--r-- | db/migrations/20210612181508_init_referrals.js | 24 | ||||
| -rw-r--r-- | db/migrations/20210612192804_init_waiting_list.js.js | 24 | ||||
| -rw-r--r-- | db/migrations/20210612203333_schema_diff_merges.js | 39 | ||||
| -rw-r--r-- | db/migrations/20210625232223_add_invoice_id_to_payments.js | 13 | ||||
| -rw-r--r-- | db/migrations/20210628221727_add_webhook_to_invoices.js | 11 | ||||
| -rw-r--r-- | db/migrations/20210713174217_add_admin_to_users.js | 16 | ||||
| -rw-r--r-- | db/migrations/20210714123455_data_fixes_merge.js | 22 | ||||
| -rw-r--r-- | db/migrations/20210714123456_add_fks_merge.js | 45 | ||||
| -rw-r--r-- | db/migrations/s2/user_adjustments.js | 67 |
9 files changed, 0 insertions, 261 deletions
diff --git a/db/migrations/20210612181508_init_referrals.js b/db/migrations/20210612181508_init_referrals.js deleted file mode 100644 index 63b20ce4..00000000 --- a/db/migrations/20210612181508_init_referrals.js +++ /dev/null @@ -1,24 +0,0 @@ -export const up = function(knex) { - return Promise.all([ - knex.schema.dropTableIfExists('referrals'), - - knex.schema.createTable('referrals', function(t) { - t.increments('id').unsigned().primary(); - t.integer('user_id').nullable(); - t.foreign('user_id').references('users.id'); - - t.integer('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(true, true); - }) - ]) -}; - -export const down = function(knex) { - return knex.schema.dropTable('referrals'); -}; diff --git a/db/migrations/20210612192804_init_waiting_list.js.js b/db/migrations/20210612192804_init_waiting_list.js.js deleted file mode 100644 index 0cef7356..00000000 --- a/db/migrations/20210612192804_init_waiting_list.js.js +++ /dev/null @@ -1,24 +0,0 @@ -export const up = function(knex) { - - return Promise.all([ - knex.schema.dropTableIfExists('waiting_list'), - - 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.integer('user_id').nullable(); - t.foreign('user_id').references('users.id'); - t.text('notes').nullable(); - - t.timestamps(true, true); - }) - ]) -}; - -export const down = function(knex) { - return knex.schema.dropTable('waiting_list'); -}; diff --git a/db/migrations/20210612203333_schema_diff_merges.js b/db/migrations/20210612203333_schema_diff_merges.js deleted file mode 100644 index 418105d2..00000000 --- a/db/migrations/20210612203333_schema_diff_merges.js +++ /dev/null @@ -1,39 +0,0 @@ -export const up = function(knex) { - return Promise.all([ - knex.schema.dropTableIfExists('reset'), - knex.schema.dropTableIfExists('naughty'), - knex.schema.dropTableIfExists('cheaters'), - - knex.raw("UPDATE accounts set createdAt = '2020-01-01' where createdAt < '2020-01-01'"), - knex.raw("UPDATE accounts set updatedAt = '2020-01-01' where updatedAt < '2020-01-01'"), - knex.raw("ALTER TABLE accounts modify `contract` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL"), - - knex.schema.alterTable('orders', function(t) { - t.dropColumn('a1'); - t.dropColumn('a2'); - }), - - knex.schema.alterTable("users", function(t) { - t.string('authyId').nullable(); - t.dropColumn('symbol'); - }), - - knex.raw("ALTER TABLE users MODIFY `subscriptions` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL"), - - ]) -}; - -export const down = async function(knex) { - return Promise.all([ - knex.schema.table("orders", function(t) { - t.integer("a1"); - t.integer("a2") - }), - - knex.schema.table("users", function(t) { - t.string("symbol"); - t.dropColumn("unit"); - t.dropColumn("authyId"); - }), - ]) -};
\ No newline at end of file diff --git a/db/migrations/20210625232223_add_invoice_id_to_payments.js b/db/migrations/20210625232223_add_invoice_id_to_payments.js deleted file mode 100644 index adf99d24..00000000 --- a/db/migrations/20210625232223_add_invoice_id_to_payments.js +++ /dev/null @@ -1,13 +0,0 @@ -export const up = async function (knex) { - return knex.schema.table("payments", function(table) { - table.integer("invoice_id"); - table.foreign("invoice_id").references("invoices.id"); - }) -}; - -export const down = async function (knex) { - return knex.schema.table("payments", function(table) { - table.dropForeign("invoice_id"); - table.dropColumn("invoice_id"); - }) -}; diff --git a/db/migrations/20210628221727_add_webhook_to_invoices.js b/db/migrations/20210628221727_add_webhook_to_invoices.js deleted file mode 100644 index 434819e5..00000000 --- a/db/migrations/20210628221727_add_webhook_to_invoices.js +++ /dev/null @@ -1,11 +0,0 @@ -export const up = async function(knex) { - return knex.schema.table("invoices", function(table) { - table.text("webhook"); - }); -}; - -export const down = async function(knex) { - return knex.schema.table("invoices", function(table) { - table.dropColumn("webhook"); - }); -}; diff --git a/db/migrations/20210713174217_add_admin_to_users.js b/db/migrations/20210713174217_add_admin_to_users.js deleted file mode 100644 index 879c8cb7..00000000 --- a/db/migrations/20210713174217_add_admin_to_users.js +++ /dev/null @@ -1,16 +0,0 @@ -export const up = async function(knex) { - return knex.schema.table("users", function(t) { - t.boolean("admin"); - t.string('email'); - t.string('phone'); - - }); -}; - -export const down = async function(knex) { - return knex.schema.table("users", function(t) { - t.dropColumn("admin"); - t.dropColumn('email') - t.dropColumn('phone') - }); -}; diff --git a/db/migrations/20210714123455_data_fixes_merge.js b/db/migrations/20210714123455_data_fixes_merge.js deleted file mode 100644 index dfe96509..00000000 --- a/db/migrations/20210714123455_data_fixes_merge.js +++ /dev/null @@ -1,22 +0,0 @@ -export const up = function(knex) { - return Promise.all([ - knex.raw("delete from invoices where invoices.account_id not in (select id from accounts)"), - knex.raw("delete from orders where orders.a1_id not in (select id from accounts) or orders.a2_id not in (select id from accounts)"), - knex.raw("update users set account_id = 10427 where id = 6262 and account_id = 10428"), - knex.raw("delete from payments where account_id not in (select id from accounts)"), - knex.raw("alter table orders drop rate"), - knex.raw("alter table orders add rate double"), - knex.raw("update orders set rate = v1/v2"), - - knex.raw('update accounts left join users on accounts.user_id = users.id set user_id = null where length(username) > 32'), - knex.raw('update accounts left join users on accounts.user_id = users.id set user_id = null where users.id is null'), - knex.raw('delete from accounts where user_id is null'), - knex.raw('delete from users where length(username) > 32') - ]) -}; - -export const down = function(knex) { - return Promise.all([ - - ]) -}; diff --git a/db/migrations/20210714123456_add_fks_merge.js b/db/migrations/20210714123456_add_fks_merge.js deleted file mode 100644 index 3d5f3e94..00000000 --- a/db/migrations/20210714123456_add_fks_merge.js +++ /dev/null @@ -1,45 +0,0 @@ -export const up = function(knex) { - return Promise.all([ - - // alter table invoices add foreign key (user_id) references users (id); - // alter table invoices add foreign key (account_id) references accounts (id); - knex.schema.alterTable("invoices", function(t) { - t.foreign('user_id').references('users.id') - t.foreign('account_id').references('accounts.id') - t.index('updatedAt') - }), - - // alter table payments add foreign key (user_id) references users (id); - // alter table payments add foreign key (account_id) references accounts (id); - knex.schema.alterTable("payments", function(t) { - t.foreign('user_id').references('users.id') - t.foreign('account_id').references('accounts.id') - t.index('updatedAt') - }), - - // alter table orders add foreign key (user_id) references users (id); - // alter table orders add foreign key (a1_id) references accounts (id); - // alter table orders add foreign key (a2_id) references accounts (id); - knex.schema.alterTable("orders", function(t) { - t.foreign('user_id').references('users.id') - t.foreign('a1_id').references('accounts.id') - t.foreign('a2_id').references('accounts.id') - t.index('updatedAt') - }), - - // alter table deposits add foreign key (user_id) references users (id) - knex.schema.alterTable("deposits", function(t) { - t.foreign('user_id').references('users.id') - t.index('updatedAt') - }), - - // alter table withdrawals add foreign key (user_id) references users (id) - knex.schema.alterTable("withdrawals", function(t) { - t.foreign('user_id').references('users.id') - t.index('updatedAt') - }), - ]) -}; - -export const down = function(knex) { -}; diff --git a/db/migrations/s2/user_adjustments.js b/db/migrations/s2/user_adjustments.js deleted file mode 100644 index cbe17977..00000000 --- a/db/migrations/s2/user_adjustments.js +++ /dev/null @@ -1,67 +0,0 @@ - -export const up = function(knex) { - return Promise.all([ - - // move security fields to separate t (potentially different access permissions) - - knex.schema.createTable('user_security', function (t) { - t.increments('id').unsigned().primary(); - t.int('user_id').notNull(); - t.foreign('user_id').references('users.user_id'); - - t.boolean('twofa').notNull().defaultTo(false); - t.string('pin').notNull(); - t.string('otp_secret').nullable(); - t.string('seed').nullable(); - }), - - knex.raw("INSERT INTO user_security (user_id, twofa, pin, otp_secret, seed) SELECT users.id, twofa, pin, otpsecret, seed FROM users"), - - // move user-customizeable fields to separate t (potentially different access permissions) - - knex.schema.createTable('user_preferences', function (t) { - t.increments('id').unsigned().primary(); - t.int('user_id').notNull(); - t.foreign('user_id').references('users.user_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'); - }), - - knex.raw("INSERT INTO user_preferences (user_id, default_unit, default_currency, default_fiat, show_currencies) SELECT users.id, unit, currency, fiat, currencies FROM users"), - - // remove deprecated fields - - knex.schema.table('users', function (t) { - t.string('uuid'); - t.enum('access', ['Anonymous', 'Member', 'Admin']).defaultTo('Anonymous'); - - t.dropColumn('account_id'); - t.dropColumn('unit'); - t.dropColumn('fiat'); - t.dropColumn('currency'); - t.dropColumn('currencies'); - }) - ]) - -}; - -export const down = function(knex) { - return Promise.all([ - knex.schema.table('users', function (t) { - t.dropColumn('uuid'); - t.dropColumn('access'); - - t.int('account_id'); - t.string('unit'); - t.string('fiat'); - t.string('currency'); - t.string('currencies'); - }), - - knex.schema.dropTable('user_preferences'), - knex.schema.dropTable('user_security'), - ]); -}; |
