Skip to content

Commit

Permalink
Automatically add new table columns
Browse files Browse the repository at this point in the history
This will be done via sql statements for now, because I'm not sure
how to run `skeema push` automatically.
  • Loading branch information
tobil4sk committed Apr 12, 2024
1 parent cb99772 commit 2845fcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/haxelib/server/Update.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package haxelib.server;

import sys.db.TableCreate;
import haxelib.server.SiteDb;

/**
Expand Down Expand Up @@ -32,6 +31,12 @@ class Update {
}

static function rehashPasswords() {
// add missing columns first
sys.db.Manager.cnx.request("
ALTER TABLE User
ADD COLUMN salt binary(32) NOT NULL;
");

// script used to update password hashes from md5 to md5 rehashed with argon2id
var users = User.manager.all();

Expand Down
4 changes: 4 additions & 0 deletions test/tests/integration/TestServerDatabaseUpdate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class TestServerDatabaseUpdate extends IntegrationTests {
// ignore salt
user.insert();
}
sys.db.Manager.cnx.request("
ALTER TABLE User
DROP COLUMN salt;
");
}

function testUpdate() {
Expand Down

0 comments on commit 2845fcb

Please sign in to comment.