Rails migrations and Capistrano don’t mix

Last night I learned the hard way what happens when Rails migrations break.

My main project, the Wiki Ed Dashboard, is set up for automatic deployment — via Capistrano and travis-ci— whenever we push new commits to the staging or production branch. It’s mostly nice.

But I ran some migrations yesterday that I shouldn’t have. In particular, this one added three new columns to a table. When I pushed it to staging, the migration took about 5 minutes and then finished. Since the staging app was unresponsive during that time, I waited until the evening to deploy it to production. But things went much worse on production, which has a somewhat large database. The migration took more than 10 minutes — at which point, travis-ci decides that the build has become unresponsive, and kills it. The migration didn’t complete.

No problem, I thought, I’ll just run the migration again. Nope! It tursn out that the first column from that migration actually made it into the MySQL database. Running it again triggered a duplicate column error. Hmmm… okay. Maybe all the columns got added, but the migration didn’t get added to the database? So I manually added the migration id to the schema_migrations table. Alas, no. Things are still broken, because the other two columns didn’t actually get added.

That’s why Rails migrations have an up and a down version, right? I’ll just migrate that one down and back up. But with only one of three columns present, neither the up nor the down migration would run. I ended up writing an ad-hoc migration to add just the second and third columns, deploying it from my own machine, and then deleting the migration afterwards. I fixed production, but it wasn’t pretty.

My takeaway from this: if you deploy via Capistrano — and especially if you deploy straight from your continuous integration server — then write a separate migration for every little thing. When things go bad in the middle of deployment, you don’t want to be stuck with a half-completed migration.

247 thoughts on “Rails migrations and Capistrano don’t mix”

  1. Automatically changing schemas scares me for this reason. I always make schema changes be a manual step that a human runs, and can make them run prior to deploying the code that requires them to exist…

    1. I got a similar response from one of the dev’s at WINTR, who suggested just scp’ing the migration to the server beforehand and running it manually. But that means continuous delivery is a LIE!

    1. Long standing but unrecognized congestive heart failure may present acutely; similarly, an acute presentation may represent an acute onset of acquired cardiac disease myocarditis or arrhythmia cialis 20mg price I would highly recommend you take your dog to your vet or the ER right away

    1. cialis professional Metformin associated lactic acidosis was characterized by elevated blood lactate concentrations 5 mmol L, anion gap acidosis without evidence of ketonuria or ketonemia, and an increased lactate pyruvate ratio; metformin plasma levels generally 5 mcg mL

  2. plant viagra Tamoxifen is not universally effective but metabolizes differently among women, where ultrarapid or extensive metabolizers are hypothesized to receive the most benefit from tamoxifen, while intermediate or poor metabolizers receive little benefit 16

  3. drug information and news for professionals and consumers. What side effects can this medication cause?
    get mobic
    Drugs information sheet. Some trends of drugs.

  4. Comprehensive side effect and adverse reaction information. Some are medicines that help people when doctors prescribe. amoxil generic
    safe and effective drugs are available. Get here.

  5. I agree with your point of view, your article has given me a lot of help and benefited me a lot. Thanks. Hope you continue to write such excellent articles.

  6. Commonly Used Drugs Charts. Comprehensive side effect and adverse reaction information. https://amoxicillins.com/ amoxicillin order online no prescription
    Get warning information here. Comprehensive side effect and adverse reaction information.

  7. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  8. certainly like your web site however you need to take a look at the spelling on several of your posts. Many of them are rife with spelling issues and I find it very bothersome to tell the truth then again I will definitely come back again.

  9. certainly like your web-site but you have to check the spelling on several of your posts. Several of them are rife with spelling problems and I find it very troublesome to tell the truth nevertheless I’ll definitely come back again.

  10. Hey very nice site!! Guy .. Beautiful .. Amazing .. I will bookmark your web site and take the feeds also?KI am happy to search out numerous helpful info here within the publish, we’d like develop extra strategies on this regard, thank you for sharing. . . . . .

  11. I like the helpful info you supply on your articles. I’ll bookmark your weblog and check again right here frequently. I’m slightly certain I’ll be told a lot of new stuff right right here! Good luck for the next!

  12. Some are medicines that help people when doctors prescribe. drug information and news for professionals and consumers.
    https://viagrapillsild.com/# sildenafil prices in india
    Medscape Drugs & Diseases. Learn about the side effects, dosages, and interactions.

  13. Just want to say your article is as astonishing. The clearness in your post is just nice and i can assume you are an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please keep up the rewarding work.

  14. Definitive journal of drugs and therapeutics. Comprehensive side effect and adverse reaction information.
    https://tadalafil1st.com/# cialis dapoxetine overnight shipping canada
    Comprehensive side effect and adverse reaction information. Read information now.

  15. Ирригатор (также известен как оральный ирригатор, ирригатор полости рта или дентальная водяная нить) – это устройство, используемое для очистки полости рта. Оно представляет собой насадку с форсункой, которая использует воду или жидкость для очистки полости рта. Ирригаторы применяются для удаления зубного камня, бактерий и насадок из полости рта, а также для смягчения любых застывших остатков пищи и органических отходов. Ирригаторы применяются для профилактики и лечения различных патологий полости рта. Наиболее распространенные ирригаторы используются для удаления зубного камня, лечения десны, профилактики и лечения воспалений десен, а также для лечения пародонтита. Кроме того, ирригаторы используются для анестезии полости рта, а также для применения антибактериальных препаратов.. Click Here:👉 https://www.irrigator.ru/irrigatory-cat.html

  16. Wow, fantastic blog structure! How lengthy have you ever been blogging for? you make running a blog glance easy. The overall look of your web site is magnificent, let alone the content material!

  17. I would like to convey my respect for your kindness in support of folks who require help with the concern. Your special commitment to passing the solution all around had become remarkably informative and has frequently allowed workers just like me to realize their goals. Your personal important report entails a lot to me and even more to my mates. With thanks; from each one of us.

  18. With havin so much content do you ever run into any problems of plagorism or copyright infringement? My site has a lot of completely unique content I’ve either written myself or outsourced but it looks like a lot of it is popping it up all over the web without my permission. Do you know any ways to help protect against content from being ripped off? I’d really appreciate it.

  19. Hi my friend! I want to say that this article is amazing, great written and include approximately all significant infos. I would like to look extra posts like this.

  20. You actually make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complex and extremely broad for me. I’m looking forward for your next post, I will try to get the hang of it!

  21. I just like the helpful information you supply to your articles. I’ll bookmark your blog and take a look at once more here frequently. I am somewhat certain I’ll be told lots of new stuff right right here! Best of luck for the following!

  22. Thanks for the sensible critique. Me & my neighbor were just preparing to do some research about this. We got a grab a book from our area library but I think I learned more clear from this post. I’m very glad to see such excellent information being shared freely out there.

  23. I happen to be writing to make you know of the great discovery my daughter went through reading through your web page. She learned a good number of things, which include what it’s like to possess a marvelous teaching nature to let certain people really easily understand some hard to do things. You truly did more than our expected results. Thank you for providing those beneficial, trusted, informative and as well as easy thoughts on that topic to Lizeth.

  24. Excellent blog right here! Also your web site quite a bit up very fast! What web host are you using? Can I am getting your affiliate link for your host? I wish my web site loaded up as quickly as yours lol

  25. I?¦ve been exploring for a bit for any high-quality articles or weblog posts on this sort of house . Exploring in Yahoo I eventually stumbled upon this web site. Studying this info So i?¦m happy to convey that I’ve a very just right uncanny feeling I came upon exactly what I needed. I so much surely will make sure to do not omit this website and provides it a look regularly.

  26. I do trust all the ideas you’ve presented on your post. They are very convincing and will certainly work. Nonetheless, the posts are very brief for novices. Could you please lengthen them a little from next time? Thanks for the post.

  27. That is the correct blog for anybody who desires to search out out about this topic. You understand so much its almost onerous to argue with you (not that I really would need…HaHa). You positively put a brand new spin on a topic thats been written about for years. Nice stuff, simply nice!

  28. I like what you guys are up too. Such intelligent work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my site 🙂

  29. I simply couldn’t depart your website prior to suggesting that I extremely loved the usual information a person supply in your visitors? Is gonna be again frequently in order to inspect new posts

  30. Virtually all of whatever you mention happens to be supprisingly precise and it makes me ponder the reason why I had not looked at this in this light previously. Your piece really did switch the light on for me personally as far as this subject matter goes. Nevertheless there is one particular factor I am not too comfy with and while I try to reconcile that with the core theme of your issue, permit me observe exactly what the rest of the subscribers have to point out.Well done.

  31. Good blog! I really love how it is easy on my eyes and the data are well written. I am wondering how I could be notified whenever a new post has been made. I’ve subscribed to your RSS which must do the trick! Have a great day!

  32. Aw, this was a very nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make an excellent article… but what can I say… I procrastinate alot and under no circumstances appear to get something done.

  33. Hi there! This is my first comment here so I just wanted to give a quick shout out and say I truly enjoy reading through your posts. Can you suggest any other blogs/websites/forums that cover the same topics? Thanks!

  34. My husband and i were very lucky that Emmanuel managed to round up his research from the ideas he gained using your blog. It is now and again perplexing to simply choose to be giving freely methods that many some other people may have been trying to sell. And we also realize we have the website owner to give thanks to for this. The specific illustrations you’ve made, the straightforward site menu, the friendships you will make it easier to foster – it’s everything fantastic, and it is making our son and the family understand that matter is thrilling, and that is exceedingly mandatory. Many thanks for all the pieces!

  35. I must point out my affection for your generosity supporting persons that have the need for help on in this area of interest. Your very own dedication to passing the message across appeared to be pretty helpful and have constantly empowered guys and women much like me to achieve their goals. The insightful key points can mean a lot to me and substantially more to my office workers. Thanks a ton; from everyone of us.

  36. I have not checked in here for a while as I thought it was getting boring, but the last several posts are great quality so I guess I¦ll add you back to my daily bloglist. You deserve it my friend 🙂

  37. Awesome blog! Do you have any recommendations for aspiring writers? I’m hoping to start my own site soon but I’m a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any ideas? Bless you!

  38. You actually make it appear really easy along with your presentation however I find this topic to be really something that I believe I’d never understand. It sort of feels too complicated and very broad for me. I am looking ahead on your next put up, I will attempt to get the hold of it!

  39. It?¦s really a nice and useful piece of information. I?¦m satisfied that you just shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *