Skip to content

Commit

Permalink
Do not run updates on fresh databases
Browse files Browse the repository at this point in the history
  • Loading branch information
tobil4sk committed Apr 12, 2024
1 parent 2845fcb commit 60283ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/haxelib/server/SiteDb.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 9 additions & 0 deletions src/haxelib/server/Update.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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("
Expand Down

0 comments on commit 60283ff

Please sign in to comment.