Feature/eng 39 multi schema foundation#21
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/ai_trading_discipline_copilot/models/user.py (1)
67-71: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
inherit_schema=Truefor schema-bound enums.Instead of hardcoding
schema="auth", you can useinherit_schema=True. This allows theEnumto automatically inherit the schema defined in__table_args__, reducing duplication and preventing mismatches if the table is ever moved to another schema.♻️ Proposed refactor
Enum( UserRole, name="user_role", - schema="auth", + inherit_schema=True, ),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/ai_trading_discipline_copilot/models/user.py` around lines 67 - 71, Update the Enum declaration in the User model to use inherit_schema=True instead of hardcoding schema="auth", allowing it to inherit the schema from __table_args__ while preserving the existing user_role name and UserRole type.alembic/env.py (1)
42-42: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider filtering schemas to avoid noisy autogenerations.
Enabling
include_schemas=Truecorrectly allows Alembic to track your multi-schema setup. However, it also causes Alembic to reflect all schemas in the database. If your database eventually uses external extensions (like PostGIS) that create their own schemas or tables, Alembic may generate unintended migrations to drop them.As the project grows, consider implementing an
include_namefunction incontext.configure()to restrict Alembic's scope strictly to your application schemas.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@alembic/env.py` at line 42, Add an include_name filter to the context.configure() call near include_schemas=True so Alembic reflects only the application’s intended schemas and objects, excluding external extension schemas such as PostGIS. Preserve multi-schema tracking while preventing autogenerate from proposing changes to unrelated database objects.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/fixtures/database.py`:
- Around line 47-50: Update the database setup around Base.metadata.create_all
to restore Base.metadata.drop_all for cleaning all managed tables, then create
every required enterprise schema (including auth, market, and risk) before
running create_all. Avoid hardcoding only the auth schema so public tables are
reset and all model schemas exist.
---
Nitpick comments:
In `@alembic/env.py`:
- Line 42: Add an include_name filter to the context.configure() call near
include_schemas=True so Alembic reflects only the application’s intended schemas
and objects, excluding external extension schemas such as PostGIS. Preserve
multi-schema tracking while preventing autogenerate from proposing changes to
unrelated database objects.
In `@src/ai_trading_discipline_copilot/models/user.py`:
- Around line 67-71: Update the Enum declaration in the User model to use
inherit_schema=True instead of hardcoding schema="auth", allowing it to inherit
the schema from __table_args__ while preserving the existing user_role name and
UserRole type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 442bdd8b-5fa9-4332-b2f3-5d08f16c3ed6
📒 Files selected for processing (9)
alembic/env.pyalembic/versions/021805c35a4a_create_enterprise_schemas.pyalembic/versions/13a89530c1d2_move_auth_tables_to_auth_schema.pydocs/architecture/multi-schema-plan.mdsrc/ai_trading_discipline_copilot/models/email_verification_token.pysrc/ai_trading_discipline_copilot/models/password_reset_token.pysrc/ai_trading_discipline_copilot/models/refresh_token.pysrc/ai_trading_discipline_copilot/models/user.pytests/fixtures/database.py
Summary
Implemented the enterprise multi-schema database foundation.
Changes
authschemauser_roleenum to theauthschemaValidation
authschemaauthschemaBreaking Changes
None.
Summary by CodeRabbit