diff --git a/src/haxelib/server/SiteDb.hx b/src/haxelib/server/SiteDb.hx index 6ca3a9da..90de951c 100644 --- a/src/haxelib/server/SiteDb.hx +++ b/src/haxelib/server/SiteDb.hx @@ -154,11 +154,22 @@ class SiteDb { Developer.manager, Meta.manager ]; - for (m in managers) - if (!TableCreate.exists(m)) + + var hasOldTables = false; + + for (m in managers) { + if (TableCreate.exists(m)) { + hasOldTables = true; + } else { TableCreate.create(m); + } + } - Update.runNeededUpdates(); + if (hasOldTables) { + Update.runNeededUpdates(); + } else { + Update.setupFresh(); + } } static public function cleanup() { diff --git a/src/haxelib/server/Update.hx b/src/haxelib/server/Update.hx index 0dc881ac..23509bdb 100644 --- a/src/haxelib/server/Update.hx +++ b/src/haxelib/server/Update.hx @@ -30,6 +30,15 @@ class Update { meta.update(); } + /** + Sets up a fresh database + **/ + public static function setupFresh() { + var meta = new Meta(); + meta.dbVersion = CURRENT_VERSION; + meta.insert(); + } + static function rehashPasswords() { // add missing columns first sys.db.Manager.cnx.request("