diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-14 17:04:20 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-14 17:04:20 +0100 |
commit | cfa344dbffa0488a9c72efdb481b8cdf87f0ac11 (patch) | |
tree | 05b8b23c05873579dc425fbf4eb00577eef43687 /core/src/ch | |
parent | 74c125481ec63e44b250475068b4d537c20eb8f7 (diff) | |
download | RustAndDust-cfa344dbffa0488a9c72efdb481b8cdf87f0ac11.zip RustAndDust-cfa344dbffa0488a9c72efdb481b8cdf87f0ac11.tar.gz |
DB: implement dropTables used in schema update
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/rustanddust/util/DB.java | 18 |
1 files 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; |