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_...

fabem
  • 113
  • 1
  • 6
  • 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 '18 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 '18 at 12:52
  • Did you try to add the --reset prameter? – ivicaa Apr 27 '18 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 '18 at 14:07
  • the console log of this situation: https://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 '18 at 14:16

1 Answers1

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
Alex 75
  • 103
  • 4
Juuso
  • 345
  • 4
  • 11
  • 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 '21 at 11:39
  • You can use "-from", with 1 hypens, or "--f", with 2 hypens. "--from" does not exists. – Alex 75 Oct 11 '22 at 06:43