11

Is it possible to truffle migrate only one specific file?

I found this on the internet: https://github.com/trufflesuite/truffle-migrate/issues/23

but truffle migrate -from 2 starts to migrate from file 2_... and goes then to the next. My goal is to migrate only file 2_...

5
  • 1
    In the issue you're linking, people are also mentioning a --to parameter. Did you try -f 2 --to 2? It worked for me.
    – ivicaa
    Apr 24, 2018 at 17:55
  • @ivicaa Sorry my bad, I miss read this. Thanks a lot for your help - its working :) Just another question: when I run truffle migrate for file 3_... and this deploy fails - how can I retry only this deploy 3_... again? Because it says "network is up to date" but the transaction failed and isnt even visible on rinkeby network. When I use --reset it starts to deploy again all files.
    – fabem
    Apr 27, 2018 at 12:52
  • Did you try to add the --reset prameter?
    – ivicaa
    Apr 27, 2018 at 12:53
  • yes, with --reset its working but he is going to deploy then all files again and my goal is to redeploy only one file after its somehow failed. I just had this situation on rinkeby: I ran truffle migrate 3_... it contains 2 SC, one he deployed fine the second one ran into a problem (I think it was a problem of rinkeby network). I saw on my geth node that it received the deploy transaction but it didnt arrive to rinkeby network
    – fabem
    Apr 27, 2018 at 14:07
  • the console log of this situation: pastebin.com/DB6whBTH and when I retried to deploy it again it said network is up to date. But obviously it ran into a problem. The only help in this situation was --reset and rename all other migration files to x_... so he did deploy only 3_... I am just not sure if this was the best solution :p
    – fabem
    Apr 27, 2018 at 14:16

1 Answer 1

12

Use the flag --f for the first migration and --to for the last migration like this:

truffle migrate --f 2 --to 2

Source: https://github.com/trufflesuite/truffle-migrate/issues/23#issuecomment-401290273

The "from" parameter can be written in two forms:

  • -from N
  • --f N
2
  • for some reasons it gives me "> Warning: possible unsupported (undocumented in help) command line option: --from" and keep running from the first script
    – lebed2045
    Sep 23, 2021 at 11:39
  • You can use "-from", with 1 hypens, or "--f", with 2 hypens. "--from" does not exists.
    – Alex 75
    Oct 11, 2022 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.