- tests/test_database.py: add user_imap_accounts table to the regression
test's initial DB setup (migration 022 creates it before rev 026, so it
must exist for migration 032's ALTER TABLE to succeed)
- tests/test_local_auth.py: configure mock_request.headers.get to return
None and client=None so get_client_ip() returns "unknown" instead of an
un-serialisable MagicMock that broke the audit_logs INSERT in
test_local_login_success and test_local_login_by_email
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
Migration 025_add_shared_links was inserted into the Alembic chain
(between 024_add_api_tokens and 025_add_user_notifications) after some
databases had already been migrated past that point. Those databases
never had the shared_links table created, causing OperationalError when
the expire-shared-links scheduled task runs or when users try to create
shared links.
This commit:
- Adds migration 027_ensure_shared_links_table that idempotently creates
the table if it doesn't exist
- Updates migrations/env.py to import all models for autogenerate support
- Adds shared_links to db_migrate.py _TABLE_ORDER for proper migration
ordering
- Adds a regression test verifying the fix
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
When init_db() called Base.metadata.create_all() before Alembic migrations,
the ORM model created the webhook_configs table. Alembic migration 009 then
failed with OperationalError: table webhook_configs already exists.
Fix: check for alembic_version table before calling create_all(). Tracked
databases skip create_all and let Alembic handle all schema changes instead.
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
- Replace bare Exception catches with sa.exc.OperationalError in migration 007
- Use ScriptDirectory.get_heads() for dynamic revision ID assertions in tests
- Make migration count assertion flexible (>= 8 instead of == 8)
- Rewrite pending migrations test to actually test upgrade from revision 006
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
- Rename test for clarity (fallback_to_builtin_template_when_custom_template_fails)
- Add MIME type validation for SVG logo test
- Use precise assertion for logo location check count
- Add column type validation in migration test
- All 39 tests pass
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
- Added tests for database.py migration functions
- Added tests for error handling in init_db()
- Added tests for file path columns migration
- Added tests for unique index dropping
- Added tests for idempotent migrations
- Added tests for email template fallback logic
- Added tests for SVG logo attachment
- Added tests for SMTP without TLS and without auth
- Added tests for timeout errors in SMTP
- Added tests for upload_to_email task validation
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>