From cfa344dbffa0488a9c72efdb481b8cdf87f0ac11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 14 Mar 2016 17:04:20 +0100 Subject: DB: implement dropTables used in schema update --- core/src/ch/asynk/rustanddust/util/DB.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index b733cc0..2e108ca 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -79,8 +79,10 @@ public class DB Boolean version = checkVersion(); if(version == null) createTables(); - else if (version == false) - System.err.println("TODO update schema"); + else if (version == false) { + dropTables(); + createTables(); + } } private void createTables() @@ -97,6 +99,18 @@ public class DB } } + private void dropTables() + { + try { + exec("drop table if exists turns"); + exec("drop table if exists states"); + exec("drop table if exists games"); + exec(String.format("update config set value=%d where key='version';", DB_SCHEMA_VERSION)); + } catch (SQLiteGdxException e) { + RustAndDust.error("table creation error " + e.getMessage()); + } + } + private String getDigest(String str) { String hash = null; -- cgit v1.1-2-g2b99