Fix startup migrations

This commit is contained in:
gabdevele
2026-06-02 19:26:27 +02:00 Unverified
parent 47cb69b829
commit a41911db39
4 changed files with 34 additions and 2 deletions
+18
View File
@@ -29,6 +29,24 @@ cmake --build build
The API listens on `http://localhost:5555`.
MailHog listens on `http://localhost:8025`.
Local seeded admin:
- email: `[email protected]`
- password: `ChangeMe123!`
- the account has `must_change_password = true` and is for local development only.
If you already had a MySQL volume from the old scaffold, create the local
database/user once:
```bash
docker compose exec -T mysql mysql -uroot -proot -e \
"CREATE DATABASE IF NOT EXISTS visione CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; \
CREATE USER IF NOT EXISTS 'visione'@'%' IDENTIFIED BY 'visione'; \
ALTER USER 'visione'@'%' IDENTIFIED BY 'visione'; \
GRANT ALL PRIVILEGES ON visione.* TO 'visione'@'%'; \
FLUSH PRIVILEGES;"
```
```bash
curl http://localhost:5555/api/v1/health
curl http://localhost:5555/api/v1/ready
+1 -1
View File
@@ -8,6 +8,7 @@
- Drogon backend structure for auth, reports, admin data and stats.
- OTP email delivery through MailHog.
- Focused regression tests for technical endpoints and core validation helpers.
- Local admin seed: `[email protected]` / `ChangeMe123!`, with forced password change flag.
## To do next
- Harden password hashing with Argon2id or bcrypt before production.
@@ -17,4 +18,3 @@
- Add file upload handling for real multipart photo upload.
- Add notification channels, route optimization and open-data exports.
- Dockerize the backend only for final delivery/deployment.
+10
View File
@@ -21,7 +21,17 @@ int main(int argc, char *argv[])
.getCustomConfig()
.get("migrations_path", "migrations")
.asString();
drogon::app().getLoop()->runAfter(0.0, [migrationsPath]() {
try
{
visione::repositories::MigrationRunner::run(migrationsPath);
}
catch (const std::exception &error)
{
LOG_FATAL << "Migration failed: " << error.what();
drogon::app().quit();
}
});
drogon::app().run();
return 0;
+4
View File
@@ -0,0 +1,4 @@
UPDATE users
SET password_hash = 'sha256$local-dev-salt$CD4FF6AC8C9685D08E55AF693970F15F9BFCD4C0DC9F4D3001D202C9DB00291F',
must_change_password = TRUE
WHERE email = '[email protected]';