-
-
Notifications
You must be signed in to change notification settings - Fork 1
[Chore] Migrate shared/database/ to penguin-dal #67
Copy link
Copy link
Open
Labels
component:databaseDatabaseDatabasepriority:highHigh priorityHigh prioritystatus:readyReady to work onReady to work ontype:choreMaintenance or toolingMaintenance or tooling
Milestone
Description
User Story
As a maintainer, I want to replace the dual PyDAL+SQLAlchemy database pattern with penguin-dal so that schema is defined once and the codebase follows penguin-libs standards.
Background
Elder currently uses a custom shared/database/ module (~4 files) implementing:
init_db(app)— PyDAL initialization withmigrate=Falseinit_sqlalchemy_tables(app)— SQLAlchemycreate_all()get_database_url(app)— URL normalization (postgresql:// vs postgres://)DatabaseManager— Read/write splitting with replica supportcreate_db_connection()— Factory with retry logicensure_database_ready()— Startup connectivity check
penguin-dal (pip install penguin-dal) replaces the entire dual-library pattern:
- Single table definition (no separate SQLAlchemy models + PyDAL define_table calls)
- Built-in connection pooling, multi-DB, async support
- Flask integration via
init_dal()/get_db() - PyDAL-identical query syntax
Per database.md: "Migrate at the next major version bump — not mid-release."
Acceptance Criteria
-
penguin-dalreplaces PyDAL + SQLAlchemy dual pattern - All table definitions consolidated (single source of truth)
-
shared/database/module removed or reduced to Elder-specific wrappers - Read/write splitting preserved (DatabaseManager equivalent)
- All existing API endpoints work without query changes
-
migrate=Falseequivalent enforced (Alembic still manages migrations) - Tests pass (unit + integration)
- Linting passes
- Security scan passes
Notes
- This is the highest-effort migration item — database layer changes carry significant risk
- Requires penguin-dal to be stable (currently v0.1.0)
- Must test all 4 supported databases: PostgreSQL, MySQL, MariaDB Galera, SQLite
shared/models/pydal_models.pytable definitions will need rewriting
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component:databaseDatabaseDatabasepriority:highHigh priorityHigh prioritystatus:readyReady to work onReady to work ontype:choreMaintenance or toolingMaintenance or tooling