views:

118

answers:

6

I'm from an clientside language programming background, specifically ActionScript. So although I'm fairly code aware I have very little server side experience, particularly version control of databases along with the rails application itself. And then there's the command line which is a complete mystery.

Right now I'm building my first rails app and looks fairly nice on my local machine. I think it's about time I started laying down some version control. Most books brush over version control stuff but it seems more complicated than building the rails app, which is going along ok. So my questions are:

  • Where to start learning this stuff?
  • Can I version control the database with the rails app together?
  • Is all this much more time consuming and complicated that building the rails app itself?
A: 

Have a look at migrations.

dhofstet
+2  A: 
  • You learn this kinda stuff by simply looking around, and trying things out, there is no substitute. Others can only suggest which tool is best for what your trying to do, but everyone has their own opinions so..yea..just do it!

  • I personally don't know how to version control a Database, but as for general version controlling your code I would suggest "git"(Link here!). It is one of the easiest and most popular Version Control systems around. Originally designed by Linus Torvalds, and is now maintained by ....

  • Yes/No, depending on how you define complicated. To create version control for your code using "git", you would initially type in

    git init

    in the directory of the code. And to add all the code to git, to tell it to keep an eye on changes in the files, you would type:

    git add *

    and then to commit(save your changes), you would type in:

    git commit -m "Type in what you have done so far"

    And thats pretty much there is to git, you would repeat the last two steps to add and save your changes as you develop your code. So if you have done something wrong to your code all you have to do is look back at your "commits" and decide where you want to back track.

    So Yea git is pretty awesome, there are others but its not as nice in my opinion. They are: SVN, CVS.

Going back to version controlling your database, Why do you want to do that? Rails has a built in Database version control, every time you change the scheme of your database, its recorded, so if you did something wrong you can always revert back! Did you mean making a backup of your Database DATA?? Cause if it is MySQL, you can always export it in xml, and version control that xml file!

chutsu
thanks that info will come in handy
conspirisi
Version control is definitely something you just need to pick, I suggest going with git as that's becoming the "rails standard".
jonnii
+1  A: 

If you're interested in version control generally the PragProg guys have a number of books on Subversion and Git (http://www.pragprog.com), look at these if you want to set up your own repository. The subversion book is also available as a free download (http://svnbook.red-bean.com/). That will give you the ability to keep your code in a version control system (something I wouldn't be without even for personal projects). If you don't want to create an manage your own version control system then there are hosted options available.

As for the database set up. Migrations are the way to go but you might find it easier to use one migration per table (i.e. edit the migration's you have rather than create new ones for each change). That way you can track all the table changes in one place. Not the traditional way to build things in Rails but it has some advantages.

One issue you have to still manage is the data in the database. If you go live and decide to rollback your database you will loose all your data, so invest in a backup/restore tool for the database.

Once you have version control in place it's generally easy to use and manage. If you are using an IDE it probably has integration into you version control system (especially if you are using SubVersion).

Kevin Jones
Another good git resource is www.gitready.com
jonnii
+2  A: 

Getting a version control system like Subversion or Git is the easy part.

The hard part is figuring out how to make it all work with a database. It's not exactly the same thing as code.

For example, will you archive just schema history or data as well? (Probably the former, but you never know.) How will you manage loading data (e.g., for test scenarios)?

Scott Ambler and Pramod Sadalange have done some work on dealing with agile databases. They recommend scripting all schema changes, and applying them in order, to bring a schema up to a particular version. Maybe this is a good place to start.

duffymo
i knew this wasn't going to be simple :)
conspirisi
A: 

I recommend starting with a simple PHP, apache, MYSql application and work up from there. The level of complexity in Rails makes it tough to jump into as a first client side app.

Joel
There's nothing special in rails that makes using version control difficult.
jonnii
If version control is the problem why would PHP solve it? -1
railsninja
A: 

I don't know that you need to version the database with git, and if you do then the repository will be quite big. I would just periodically just dump and gzip the database that you can keep for future reference. Your app's schema should be safe in your version control, and that along with your db dumps you should be fine.

If you have been coding for a while without source control. STOP. Go learn about some Version control, it will save your butt one day. Ruby, ActionScript, whatever you are writing, put it in git, or whatever you choose to use, you will be better for it. I have a check in or two before I have even written any of my own code as I add the couple of plugins etc that I need.

Check in early, check in often, same philosophy as release early release often. The more you check stuff in the more points you have to roll back to if you need, and also better you can review your progess, either toward release or your development as a coder.

railsninja