0

I want to delete a bunch of code from my application including several models.

I tried deleting the file that defines the models and then did an Alemic autogenerate but the generated migration file did not appear to remove the corresponding tables.

Any suggestions for how to do deletion in order to clear out no longer used code?

thanks

Duke Dougal
  • 24,359
  • 31
  • 91
  • 123

2 Answers2

2

In your alembic migration, in the 'upgrade' function, just do something like:

from alembic import op
for table in ('table_a', 'table_b'):
    op.drop_table(table)
Robin Davis
  • 622
  • 4
  • 10
  • So essentially I have to do it manually? I'll just doing it all using plsql then I guess. – Duke Dougal May 04 '16 at 04:27
  • 1
    @DukeDougal a bit late of an answer, but alembic isn't just about manual vs. automatic AFAIU, it's also about keeping things in order by using revisions, being able to downgrade, etc.. (so I'd accept this Robin's answer :) ) – yair May 19 '19 at 22:01
1

You can use this on the terminal:

alembic downgrade base or alembic downgrade 2438c2e44a3e where this version is the version that is before the one you want to work with. On alembic version file it is shown as down_revision = '2438c2e44a3e'

Simi Lika
  • 53
  • 8