nexusLIMS.db.migrations.env#
Alembic migration environment configuration for NexusLIMS.
This module configures the Alembic migration environment for the NexusLIMS database. It handles both online and offline migration modes and automatically configures the database URL from the NexusLIMS settings.
Key features: - Automatically reads database path from NX_DB_PATH environment variable - Configures SQLModel metadata for autogenerate support - Supports both online (live database) and offline (SQL script) migrations - Imports all SQLModel classes to ensure complete schema detection
Usage: This file is automatically used by Alembic when running migration commands: uv run alembic upgrade head uv run alembic revision –autogenerate -m “description”
.. note::
All SQLModel model classes must be imported in this file (even if not directly used) to ensure Alembic can detect them for autogenerate operations.
Module Contents#
Functions#
Alembic hook to customize revision generation. |
|
Run migrations in ‘offline’ mode. |
|
Run migrations in ‘online’ mode. |
Data#
API#
- nexusLIMS.db.migrations.env.config#
- nexusLIMS.db.migrations.env.target_metadata#
- nexusLIMS.db.migrations.env.process_revision_directives(context_obj, _revision, directives)#
Alembic hook to customize revision generation.
This is called by Alembic when creating new migrations via ‘nexuslims db alembic revision –autogenerate’.
It replaces the default random hex revision ID with a sequential numbered ID for better readability.
- nexusLIMS.db.migrations.env.run_migrations_offline() None#
Run migrations in ‘offline’ mode.
This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don’t even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the script output.