feat: add integration tests for Alembic migrations#463
Merged
Conversation
Add comprehensive test coverage for Alembic migrations to catch migration errors before deployment. Tests include: - Migration history validation (no branching, chain integrity) - Schema verification (core tables, NMA legacy tables, columns) - Foreign key integrity (data model relationships) - Index verification (spatial indexes) - Downgrade capability (skipped by default for safety) Fixes #356 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive integration tests for Alembic database migrations to catch migration errors in CI before merging. The tests verify migration history consistency, schema structure, foreign key relationships, indexes, and downgrade capability.
Changes:
- Added 16 integration tests covering migration history, schema verification, foreign key integrity, and indexes
- Tests validate core tables, NMA legacy tables, required columns, PostGIS configuration, and spatial indexes
- Included downgrade test (skipped by default to avoid schema modification)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/integration/test_alembic_migrations.py | New test file with comprehensive Alembic migration tests organized into four test classes |
| admin/views/chemistry_sampleinfo.py | Removed extraneous blank line |
Address Copilot review comment about inconsistent indentation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add missing `Request` and `HasOne` imports that were causing NameError during test collection. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests that verify all admin view modules can be imported successfully. This catches missing imports (like Request, HasOne) during CI before they cause runtime errors. Tests include: - Package-level import verification - Individual module import verification - Core view module parametrized tests - Configuration attribute validation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jirhiker
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive integration tests for Alembic migrations to ensure CI catches migration errors before merge.
Fixes #356
Changes
New test file:
tests/integration/test_alembic_migrations.pyTest Categories
Tests Added
Migration History:
test_migrations_have_no_multiple_heads- Ensures no branching in migration historytest_all_migrations_have_down_revision- Validates migration chain is unbrokentest_current_revision_matches_head- Verifies DB is at latest migrationSchema Verification:
test_core_tables_exist- Verifies 13 core tablestest_legacy_nma_tables_exist- Verifies 9 NMA legacy tablestest_thing_table_has_required_columns- Checks required columns including legacy PKstest_location_table_has_geometry_column- Verifies PostGIS geometrytest_observation_table_has_required_columns- Checks observation schematest_alembic_version_table_exists- Verifies migration trackingtest_postgis_extension_enabled- Verifies PostGIS extensionFK Integrity:
test_observation_has_sample_fktest_sample_has_field_activity_fktest_field_activity_has_field_event_fktest_field_event_has_thing_fktest_nma_chemistry_has_thing_fkIndexes:
test_location_has_spatial_index- Verifies GIST spatial indexTest Plan
🤖 Generated with Claude Code