aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrations
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-07-20 13:35:36 -0700
committerAdam Soltys <[email protected]>2021-07-20 13:35:36 -0700
commitec17ed24db4e3f9dd825166095f9f0382c35cfeb (patch)
tree361188a8c8a82513edffef7b7ae302f6bc5a2776 /db/migrations
parentbfbca2a5487c340d3158e2df856d04b86467037d (diff)
downloadcoinos-server-ec17ed24db4e3f9dd825166095f9f0382c35cfeb.tar.gz
coinos-server-ec17ed24db4e3f9dd825166095f9f0382c35cfeb.zip
update data fixes to drop invalid records
Diffstat (limited to 'db/migrations')
-rw-r--r--db/migrations/20210714123455_data_fixes_merge.js18
1 files changed, 5 insertions, 13 deletions
diff --git a/db/migrations/20210714123455_data_fixes_merge.js b/db/migrations/20210714123455_data_fixes_merge.js
index 0bbc1890..aed78258 100644
--- a/db/migrations/20210714123455_data_fixes_merge.js
+++ b/db/migrations/20210714123455_data_fixes_merge.js
@@ -1,17 +1,9 @@
exports.up = function(knex) {
return Promise.all([
-
- // check with :
- knex.raw("update invoices as m left join accounts on accounts.id=account_id left join users on users.id = m.user_id set m.account_id=users.account_id where m.account_id is not null and accounts.id is null"),
-
- knex.raw("update users left join accounts on users.account_id=accounts.id left join accounts as n on n.user_id = users.id set users.account_id=n.id where account_id is not null and accounts.id is null"),
-
- knex.raw("update payments as m left join accounts on accounts.id=account_id left join users on users.id = m.user_id set m.account_id=users.account_id where m.account_id is not null and accounts.id is null"),
-
- knex.raw("update orders as m left join accounts on accounts.id=m.a1_id left join users on users.id = m.user_id set m.a1_id=users.account_id where m.a1_id is not null and accounts.id is null"),
-
- knex.raw("update orders as m left join accounts on accounts.id=m.a2_id left join users on users.id = m.user_id set m.a2_id=users.account_id where m.a2_id is not null and accounts.id is null"),
-
+ knex.raw("delete from invoices where invoices.account_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("delete from orders where a1_id not in (select id from accounts) or a2_id not in (select id from accounts)"),
])
}
@@ -19,4 +11,4 @@ exports.down = function(knex) {
return Promise.all([
])
-} \ No newline at end of file
+}