Skip to content

Delete all tables from a specific schema version #2861

Answered by simolus3
Sandrichka22 asked this question in Q&A
Discussion options

You must be logged in to vote

Using the allTables getter to delete all the tables does not work anymore

You have access to the schema at a specific version through the schema callback passed to these migrations.

So you can use

from56To57: (m, schema) async {
        for (final table in schema.entities.whereType<TableInfo>()) {
          await m.deleteTable(table.actualTableName);
          await m.createTable(table);
        }
        await m.recreateAllViews();
      }, 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sandrichka22
Comment options

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