Skip to content

Commit 5dcc99e

Browse files
committed
refactor(database): improve Alembic configuration setup in database.py
- Updated the _create_alembic_config function to manually create the Alembic Config object, addressing issues with the toml_file parameter. - Added additional Alembic options for script location, version locations, file template, and timezone to enhance migration management. - Improved logging to provide more detailed information about the configuration being used.
1 parent ff4ded1 commit 5dcc99e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/tux/cli/database.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@
2222

2323

2424
def _create_alembic_config() -> Config:
25-
"""Create an Alembic Config object with pyproject.toml configuration."""
26-
# Create config with pyproject.toml support
27-
config = Config(toml_file="pyproject.toml")
25+
"""Create an Alembic Config object with proper configuration."""
26+
# Create config manually (toml_file parameter has issues)
27+
config = Config()
2828

2929
# Set the database URL from environment
3030
database_url = get_database_url()
3131
config.set_main_option("sqlalchemy.url", database_url)
3232

33+
# Set other required alembic options
34+
config.set_main_option("script_location", "src/tux/database/migrations")
35+
config.set_main_option("version_locations", "src/tux/database/migrations/versions")
36+
config.set_main_option("prepend_sys_path", "src")
37+
config.set_main_option(
38+
"file_template",
39+
"%%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s",
40+
)
41+
config.set_main_option("timezone", "UTC")
42+
3343
logger.info(f"Using database URL: {database_url}")
44+
logger.debug(f"Script location: {config.get_main_option('script_location')}")
3445
return config
3546

3647

0 commit comments

Comments
 (0)