Data migrations feedback [0.15.3]

Hey @rob, posted this on discord but you’re not on there often so reposting here :slight_smile:

Just tried dataMigrate - works beautifully. Thank you for this!

Some thoughts:

  • love that you have an alias for yarn rw dm :slight_smile:
  • should there be a way of rerunning a data migration from the cli (without needing to delete the entry in the db)?
  • how do you guys test the migration code you’re writing? (I don’t mean Jest, just wondering if you’re modifying your dev db, or if theres a hidden dry-run feature)
  • My build on netlify doesn’t seem to fail when data migrations fail. Is this intentional?
    :white_check_mark: solved, see post 2
1 Like

Point 4 solved by this PR. https://github.com/redwoodjs/redwood/pull/948

(Sorry for the late reply, I typed this out on Friday but never hit “Reply” for some reason!)

Glad you like them!

love that you have an alias for yarn rw dm

I didn’t actually add this so I’m not sure where that came from! :sweat_smile:

should there be a way of rerunning a data migration from the cli

Probably, but for now I just wanted to get it out the door before worrying about tasks like dataMigrate down or dataMigration rollback I actually needed data migrations for another project I’m working on so I wrote just the bare functionality I needed to get it working for my use case!

how do you guys test the migration code you’re writing?

Yeah I run them locally in development until I’m sure they’re working the way I want before pushing to production.

My build on netlify doesn’t seem to fail when data migrations fail. Is this intentional?

Hmmm, I think we catch any errors and report on them in the console, but must not have an actual process.exit(1) to make sure the build fails. I just opened an issue to add that!

No probs Rob, thanks for the reply!

Btw, I found a little “hack” when you’re testing the migration locally.

If you throw from the bottom of the migration:

  throw new Error('Debug: dont finish dm')

At the end of the migration during dev, it’ll make sure it wont’ add a record for succesfful migration. (So 1 less thing to clear down from the db, when trying to rerun)

1 Like