Fix startup migrations
This commit is contained in:
@@ -29,6 +29,24 @@ cmake --build build
|
|||||||
The API listens on `http://localhost:5555`.
|
The API listens on `http://localhost:5555`.
|
||||||
MailHog listens on `http://localhost:8025`.
|
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
|
```bash
|
||||||
curl http://localhost:5555/api/v1/health
|
curl http://localhost:5555/api/v1/health
|
||||||
curl http://localhost:5555/api/v1/ready
|
curl http://localhost:5555/api/v1/ready
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
- Drogon backend structure for auth, reports, admin data and stats.
|
- Drogon backend structure for auth, reports, admin data and stats.
|
||||||
- OTP email delivery through MailHog.
|
- OTP email delivery through MailHog.
|
||||||
- Focused regression tests for technical endpoints and core validation helpers.
|
- Focused regression tests for technical endpoints and core validation helpers.
|
||||||
|
- Local admin seed: `[email protected]` / `ChangeMe123!`, with forced password change flag.
|
||||||
|
|
||||||
## To do next
|
## To do next
|
||||||
- Harden password hashing with Argon2id or bcrypt before production.
|
- Harden password hashing with Argon2id or bcrypt before production.
|
||||||
@@ -17,4 +18,3 @@
|
|||||||
- Add file upload handling for real multipart photo upload.
|
- Add file upload handling for real multipart photo upload.
|
||||||
- Add notification channels, route optimization and open-data exports.
|
- Add notification channels, route optimization and open-data exports.
|
||||||
- Dockerize the backend only for final delivery/deployment.
|
- Dockerize the backend only for final delivery/deployment.
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,17 @@ int main(int argc, char *argv[])
|
|||||||
.getCustomConfig()
|
.getCustomConfig()
|
||||||
.get("migrations_path", "migrations")
|
.get("migrations_path", "migrations")
|
||||||
.asString();
|
.asString();
|
||||||
|
drogon::app().getLoop()->runAfter(0.0, [migrationsPath]() {
|
||||||
|
try
|
||||||
|
{
|
||||||
visione::repositories::MigrationRunner::run(migrationsPath);
|
visione::repositories::MigrationRunner::run(migrationsPath);
|
||||||
|
}
|
||||||
|
catch (const std::exception &error)
|
||||||
|
{
|
||||||
|
LOG_FATAL << "Migration failed: " << error.what();
|
||||||
|
drogon::app().quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
drogon::app().run();
|
drogon::app().run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
UPDATE users
|
||||||
|
SET password_hash = 'sha256$local-dev-salt$CD4FF6AC8C9685D08E55AF693970F15F9BFCD4C0DC9F4D3001D202C9DB00291F',
|
||||||
|
must_change_password = TRUE
|
||||||
|
WHERE email = '[email protected]';
|
||||||
Reference in New Issue
Block a user