views:

50

answers:

2

Hi,

I have a rails application in which I implemented some feature. Now I want to remove that feature without breaking the code. Since the application is running on the production server, this makes it a little bit critical. How do I do the following.

  • remove all the tables from the database concerned with this functionality?
  • remove the controllers, models and view files?
  • correct the other controllers and views which are related with this functionality?

The first one can be achieved by generating migrations which produce reverse result to that of which try to create the tables related to this functionality. How should I proceed towards the code removal? I am using git as my source code manager.

+1  A: 

Create some migrations to remove the now useless databases/fields

Remove the controllers, models and view files

Correct anything that's now broken (I hope you're writing tests)

Push your code to your staging server and check everything is properly working

When everything is ok, push your code to production. And you should roll.

Damien MATHIEU
Tests really helped me accomplishing this.
Waseem
A: 

Use git to create a separate branch (I'll call it "less"), and make all the changes on that branch. That way your site keeps running. You should have another copy of your application running somewhere (ie, on your local computer) that is running from the "less" branch.

It's vital that you have tests in order to ensure that removing features doesn't break something else unintentionally. Run your tests on the test server (running off the "less" branch).

Once your test server performs properly and your tests run okay, merge your "less" branch into your "master" branch (that your production server is running off of). Pull the changes to your production server, restart, and you're good to go.

insane.dreamer