Skip to content

I want to switch to use the make-migrations script and drop all tables from any previous schema version. Previously used manual override migrations. Best way to do this? #3301

Answered by kfieldi5
kfieldi5 asked this question in Q&A
Discussion options

You must be logged in to vote

Most future migrations will be a lot more intricate than this. I am only dropping all tables on this version so that we have a clean-slate.

My first schema file is drift_schema_v4.json

Before that I did not have schema files.

To utilize the new make-migrations script I need to call runMigrationSteps and still manually put in my addColumn's, removeColumn's, and alterTable commands? I guess I'm unclear on how to use the new automatic way.

Here is my attempt, please correct as needed:

@override
  MigrationStrategy get migration {
    return MigrationStrategy(
      onCreate: (Migrator m) async {
        await m.createAll();
      },
      onUpgrade: (Migrator m, int from, int to) async {
   …

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@kfieldi5
Comment options

Answer selected by simolus3
@simolus3
Comment options

@kfieldi5
Comment options

@simolus3
Comment options

Comment options

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

@kfieldi5
Comment options

@simolus3
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
2 participants