aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-07-28 15:59:13 -0700
committerRan Guin <[email protected]>2021-07-28 15:59:13 -0700
commitccfa3e0279cdc2e6ce0f98b25a6c158c0811efaa (patch)
tree358c730aaa077f4343a4f30d1b5b05f5e985efbb
parent9edb27f2ed7f4d1507a9abd475267d0eda1d9017 (diff)
downloadcoinos-server-ccfa3e0279cdc2e6ce0f98b25a6c158c0811efaa.tar.gz
coinos-server-ccfa3e0279cdc2e6ce0f98b25a6c158c0811efaa.zip
add deletion of users with names longer than 32 chars.. and accounts referencing these (or non-existent) users
-rw-r--r--db/migrations/20210714123455_data_fixes_merge.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/db/migrations/20210714123455_data_fixes_merge.js b/db/migrations/20210714123455_data_fixes_merge.js
index 70740ce8..d6ba3a3a 100644
--- a/db/migrations/20210714123455_data_fixes_merge.js
+++ b/db/migrations/20210714123455_data_fixes_merge.js
@@ -7,6 +7,11 @@ exports.up = function(knex) {
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 users.id is null'),
+ knex.raw('delete from users where length(username) > 32')
])
}