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 Dec 25, 2023
1 parent b4d05eb commit 38d8d9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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
5 changes: 4 additions & 1 deletion test/tests/integration/TestServerDatabaseUpdate.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tests.integration;

import haxe.io.Bytes;
import haxelib.server.Update;
import haxelib.server.Hashing;
import haxelib.server.SiteDb;
Expand Down Expand Up @@ -39,6 +38,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 38d8d9f

Please sign in to comment.