Skip to content

opt-in to disable automatic DB migration #9449

Draft
contributor wants to merge 4 commits intoTriliumNext:mainfrom
contributor:opt-in-to-manual-db-migration
Draft

opt-in to disable automatic DB migration #9449
contributor wants to merge 4 commits intoTriliumNext:mainfrom
contributor:opt-in-to-manual-db-migration

Conversation

@contributor
Copy link
Copy Markdown
Contributor

@contributor contributor commented Apr 16, 2026

This intended mostly for developers.

If you opt-in to set TRILIUM_MANUAL_DB_MIGRATION, you won't accidentally upgrade DB when switching between branches

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to disable automatic database migrations using the TRILIUM_MANUAL_DB_MIGRATION environment variable. Feedback suggests localizing the error message and integrating this setting into the central configuration system for better consistency and flexibility.

Comment on lines +138 to +140
if (process.env.TRILIUM_MANUAL_DB_MIGRATION === "true") {
await crash(`Automatic DB migrations are disabled via env var TRILIUM_MANUAL_DB_MIGRATION = ${process.env.TRILIUM_MANUAL_DB_MIGRATION}`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message should be localized using the t() function to maintain consistency with the rest of the application. Furthermore, this configuration option should ideally be integrated into the central configuration system in apps/server/src/services/config.ts. This would allow it to be documented in config-sample.ini, be configurable via config.ini, and benefit from the project's standard environment variable resolution (which handles case-insensitivity and boolean variations like 1/0).

Suggested change
if (process.env.TRILIUM_MANUAL_DB_MIGRATION === "true") {
await crash(`Automatic DB migrations are disabled via env var TRILIUM_MANUAL_DB_MIGRATION = ${process.env.TRILIUM_MANUAL_DB_MIGRATION}`);
}
if (process.env.TRILIUM_MANUAL_DB_MIGRATION?.toLowerCase() === "true") {
await crash(t("migration.manual_db_migration_disabled", { value: process.env.TRILIUM_MANUAL_DB_MIGRATION }));
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-code-assist the use case is very niche, mainly for developers or users who runs multiple app versions at the same time. There is not benefit to add more code for translations or config.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is a niche use case. However, even for niche features, it is best practice to follow the established patterns of the codebase to ensure maintainability and consistency. Using the central configuration system ensures that the setting is discoverable and consistent with how other environment variables are handled across the application, rather than relying on direct process.env access in a service file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@contributor , it's fine to add a translation for it. Please also mention it somewhere in the documentation. Even if it's niche.

@contributor contributor changed the title PERMALINK opt-in to disable automatic DB migration opt-in to disable automatic DB migration Apr 18, 2026
Comment on lines +138 to +140
if (process.env.TRILIUM_MANUAL_DB_MIGRATION === "true") {
await crash(`Automatic DB migrations are disabled via env var TRILIUM_MANUAL_DB_MIGRATION = ${process.env.TRILIUM_MANUAL_DB_MIGRATION}`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@contributor , it's fine to add a translation for it. Please also mention it somewhere in the documentation. Even if it's niche.

@contributor contributor marked this pull request as draft April 19, 2026 13:05
@contributor
Copy link
Copy Markdown
Contributor Author

it's fine to add a translation for it. Please also mention it somewhere in the documentation.

@eliandoran added translation and documentation

The code still compares the env var strictly to "true". This contradicts the docs that allows true/1.

Looks like I will have to add this to config.ts to utilize and conform boolean conversions?

Development: {
    manualDbMigration: boolean
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants