Skip to content

Make ADK table drops conditional in migrations and update tsconfig#73

Merged
stenwire merged 2 commits into
stagingfrom
main
Jul 4, 2026
Merged

Make ADK table drops conditional in migrations and update tsconfig#73
stenwire merged 2 commits into
stagingfrom
main

Conversation

@stenwire

@stenwire stenwire commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • Infrastructure / CI / tooling

Checklist

  • My code follows the existing code style of this project
  • I have tested my changes locally
  • Lint passes (make lint-be / make lint-fe)
  • Tests pass (make test-be / make test-fe)
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

Screenshots / Demo

Related Issues

stenwire and others added 2 commits July 4, 2026 21:29
…s from tsconfig

Migrations dae11b7e812a and 70d75bc52042 tried to drop app_states/events/
sessions/user_states unconditionally; fresh staging DBs don't have these
ADK-managed tables so all three migrations now check existence first.

Exclude the tests/ directory from Next.js tsconfig so the production
Docker build doesn't fail on test-only type errors (e.g. framer-motion
mock's children typed as unknown). Vitest uses its own resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: make ADK table drops conditional in all migrations, exclude test…
@stenwire
stenwire merged commit e69567a into staging Jul 4, 2026
4 checks passed
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

🤖 Hi @stenwire, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This pull request introduces valuable improvements to the database migration scripts and the frontend TypeScript configuration. The changes enhance the robustness of database migrations by making table drops conditional and improve the build process by excluding test files from the TypeScript compilation.

🔍 General Feedback

  • Positive Highlight: The conditional logic added to the Alembic migrations is a great practice. It prevents migration scripts from failing when run against a database schema that doesn't contain the tables to be dropped, making the deployment process more resilient.
  • Good Practice: Excluding the tests directory in tsconfig.json is a correct and standard configuration for Next.js/TypeScript projects, ensuring that test files are not unnecessarily included in production builds.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies database migrations to conditionally drop tables by inspecting the connection, and updates the frontend TypeScript configuration to exclude the tests directory. The feedback points out that redundant table drops across sequential migrations are an anti-pattern and suggests either removing them or using Alembic's built-in if_exists=True parameter. Additionally, it is recommended not to exclude the tests directory from tsconfig.json to preserve IDE type-checking and autocompletion support for test files.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +24 to +28
conn = op.get_bind()
existing = sa.inspect(conn).get_table_names()
for tbl in ('events', 'sessions', 'user_states', 'app_states'):
if tbl in existing:
op.drop_table(tbl)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If these two migrations are sequential in the migration chain, once the tables are dropped in the first migration, they will not exist when the second one runs. Instead of making the drops conditional in both files, the best practice is to keep the drop_table commands in the migration where they are first introduced and completely remove them from the subsequent migration.

If conditional drops are indeed necessary, you can use the built-in if_exists=True parameter supported in Alembic 1.13.3+ instead of manually inspecting the connection.

Suggested change
conn = op.get_bind()
existing = sa.inspect(conn).get_table_names()
for tbl in ('events', 'sessions', 'user_states', 'app_states'):
if tbl in existing:
op.drop_table(tbl)
for tbl in ('events', 'sessions', 'user_states', 'app_states'):
op.drop_table(tbl, if_exists=True)

Comment on lines +24 to +28
conn = op.get_bind()
existing = sa.inspect(conn).get_table_names()
for tbl in ('user_states', 'app_states', 'events', 'sessions'):
if tbl in existing:
op.drop_table(tbl)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If this migration runs after 70d75bc52042_transactions_table.py, these tables will have already been dropped. Having redundant drop_table commands across multiple sequential migrations is an anti-pattern (often caused by running autogenerate before applying previous migrations locally).

To keep the migration history clean, these redundant drop commands should be removed entirely from this migration.

Comment thread frontend/tsconfig.json
"**/*.mts"
],
"exclude": ["node_modules"]
"exclude": ["node_modules", "tests"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Excluding the tests directory from the main tsconfig.json disables TypeScript type-checking, autocompletion, and path alias resolution for all test files in IDEs/editors.

If the goal is to exclude tests from the production build output, it is better to keep them in tsconfig.json to preserve IDE support, and instead use a separate configuration (e.g., tsconfig.build.json) for the production build, or rely on Next.js/Vite which automatically ignores test files during the build process.

Suggested change
"exclude": ["node_modules", "tests"]
"exclude": ["node_modules"]

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Security Analysis Summary

No security vulnerabilities were identified in this pull request. The changes primarily consist of database migration scripts and a configuration file update, which do not introduce any security risks.

🔍 General Feedback

  • The database migration scripts are well-structured and use the Alembic API correctly.
  • The changes are small and focused, which is good for maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant