Skip to content

Creating and dropping indexes from migration scripts #1121

Answered by sinisaos
stronk7 asked this question in Q&A
Discussion options

You must be logged in to vote

@stronk7 Yes, you are right. I think the problem is in this line, because with that line

response = await migration_module.forwards()

forwards method is always called even if we use backwards in the cli. For now I can only drop the indexes if I make another empty migration and pass Table.drop_index in the forwards method.

I played around with this a bit and made these changes to the source code.
First, I added a backwards method to Jinja template like this

# all previous code is unchanged
async def backwards():
    manager = MigrationManager(migration_id=ID, app_name="{{ app_name }}", description=DE…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by stronk7
Comment options

You must be logged in to vote
2 replies
@sinisaos
Comment options

@stronk7
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@stronk7
Comment options

@Jacky56
Comment options

@sinisaos
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants