This repository was archived by the owner on Nov 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Removing indices #93
Open
wojked
wants to merge
9
commits into
master
Choose a base branch
from
wjkd/ECP-3163-index-removal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Removing indices #93
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e26b8af
This PR removes some indices.
wojked 9124b8d
restoring settings
wojked 4afde42
linter fixes
wojked c5a3ef1
linter fixes
wojked 25c98e2
isort fixes
wojked ebdf1e0
removing indices manually
wojked 8a5df41
Migrate only on Postgres
wojked c2175d9
linter
wojked 9f2562e
Merge branch 'master' into wjkd/ECP-3163-index-removal
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
aa_stripe/migrations/0023_alter_stripecharge_customer_and_more.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Generated by Django 4.2.20 on 2025-04-29 05:03 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
| remove_indexes = [ | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_user_id_6f76c244", | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_stripe_refund_id_78d16b7f_like", | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_stripe_refund_id_78d16b7f", | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_stripe_charge_id_86aca19a", | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_stripe_charge_id_86aca19a_like", | ||
| "DROP INDEX CONCURRENTLY IF EXISTS aa_stripe_stripecharge_customer_id_a6cd951b", | ||
| ] | ||
|
|
||
|
|
||
| def drop_indexes_postgresql(apps, schema_editor): | ||
| """ | ||
| This function drops indexes for PostgreSQL database. | ||
| It will NOT run on SQLite during testing as it does NOT support: | ||
| - DROP INDEX CONCURRENTLY | ||
| - IF EXISTS | ||
| """ | ||
| if schema_editor.connection.vendor != "postgresql": | ||
| return # Skip for SQLite or other DBs | ||
|
|
||
| for sql in remove_indexes: | ||
| schema_editor.execute(sql) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ("aa_stripe", "0022_stripecharge_amount_refunded"), | ||
| ] | ||
| atomic = False # CONCURRENTLY cannot run inside a transaction block | ||
|
|
||
| operations = [ | ||
| migrations.SeparateDatabaseAndState( | ||
| database_operations=[ | ||
| migrations.RunPython( | ||
| drop_indexes_postgresql, | ||
| reverse_code=migrations.RunPython.noop, | ||
| ), | ||
| ], | ||
| state_operations=[ | ||
| migrations.AlterField( | ||
| model_name="stripecharge", | ||
| name="customer", | ||
| field=models.ForeignKey( | ||
| db_index=False, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| to="aa_stripe.stripecustomer", | ||
| ), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="stripecharge", | ||
| name="stripe_charge_id", | ||
| field=models.CharField(blank=True, max_length=255), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="stripecharge", | ||
| name="stripe_refund_id", | ||
| field=models.CharField(blank=True, max_length=255), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="stripecharge", | ||
| name="user", | ||
| field=models.ForeignKey( | ||
| db_index=False, | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="stripe_charges", | ||
| to=settings.AUTH_USER_MODEL, | ||
| ), | ||
| ), | ||
| ], | ||
| ) | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why no reverse?