finish migration commands
@@ -162,6 +162,33 @@ class Owner(commands.Cog):
await ctx.send('done.')
+ @commands.command(name='migrateusers')
+ @commands.is_owner()
+ async def migrate_users(self, ctx):
+ await ctx.send('opening db.json')
+ with open('db.json', 'r') as f:
+ data = cj.load(f)
+
+ await ctx.send('migrating items...')
+ async with self.db.acquire() as con:
+ for item in data.items:
+ await con.execute(
+ 'INSERT INTO items VALUES ($1, $2, $3, $4)',
+ item.id, item.item, item.val, item.num
+ )
+
+ await ctx.send('migrating balances...')
+ async with self.db.acquire() as con:
+ for b in data.currency:
+ await con.execute('INSERT INTO users VALUES ($1, $2, $3, $4, $5, $6, $7)', b.id, b.amount, None, None, 20, 0, False)
+
+ await ctx.send('migrating vaults...')
+ async with self.db.acquire() as con:
+ for v in data.vaults:
+ await con.execute('UPDATE users SET vault_bal = $1, vault_max = $2 WHERE uid = $3', v.amount, v.max, v.id)
+
+ await ctx.send('done')
+
def setup(bot):
bot.add_cog(Owner(bot))
