-
Notifications
You must be signed in to change notification settings - Fork 0
fix: make ADK table drops conditional in all migrations, exclude test… #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,10 +21,11 @@ | |||||||||||||||||||||||
| def upgrade() -> None: | ||||||||||||||||||||||||
| """Upgrade schema.""" | ||||||||||||||||||||||||
| # ### commands auto generated by Alembic - please adjust! ### | ||||||||||||||||||||||||
| op.drop_table('events') | ||||||||||||||||||||||||
| op.drop_table('sessions') | ||||||||||||||||||||||||
| op.drop_table('user_states') | ||||||||||||||||||||||||
| op.drop_table('app_states') | ||||||||||||||||||||||||
| 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) | ||||||||||||||||||||||||
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | ||||||||||||||||||||||||
| batch_op.add_column(sa.Column('transaction_metadata', sa.JSON(), nullable=True)) | ||||||||||||||||||||||||
| batch_op.drop_column('metadata') | ||||||||||||||||||||||||
|
Comment on lines
+24
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||
| 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) | |
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | |
| batch_op.add_column(sa.Column('transaction_metadata', sa.JSON(), nullable=True)) | |
| batch_op.drop_column('metadata') | |
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | |
| batch_op.add_column(sa.Column('transaction_metadata', sa.JSON(), nullable=True)) | |
| batch_op.drop_column('metadata') |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,10 +21,11 @@ | |||||||||||||||||||
| def upgrade() -> None: | ||||||||||||||||||||
| """Upgrade schema.""" | ||||||||||||||||||||
| # ### commands auto generated by Alembic - please adjust! ### | ||||||||||||||||||||
| op.drop_table('user_states') | ||||||||||||||||||||
| op.drop_table('app_states') | ||||||||||||||||||||
| op.drop_table('events') | ||||||||||||||||||||
| op.drop_table('sessions') | ||||||||||||||||||||
| 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) | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🟢 Good catch! This change correctly makes the migration idempotent and safer to run in different database states.
|
||||||||||||||||||||
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | ||||||||||||||||||||
| batch_op.add_column(sa.Column('raw_webhook_payload', sa.JSON(), nullable=True)) | ||||||||||||||||||||
|
Comment on lines
+24
to
30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
| 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) | |
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | |
| batch_op.add_column(sa.Column('raw_webhook_payload', sa.JSON(), nullable=True)) | |
| with op.batch_alter_table('payment_transactions', schema=None) as batch_op: | |
| batch_op.add_column(sa.Column('raw_webhook_payload', sa.JSON(), nullable=True)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,5 +31,5 @@ | |
| ".next/dev/types/**/*.ts", | ||
| "**/*.mts" | ||
| ], | ||
| "exclude": ["node_modules"] | ||
| "exclude": ["node_modules", "tests"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🟢 Excluding the `tests` directory from the main `tsconfig.json` is a good practice. This ensures that test-specific configurations and types do not interfere with the production build, which was the goal of this PR.
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.