Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Migrate vs SQL batch

migrate migration database sql

  • Please log in to reply
8 replies to this topic

#1 fabiosoft

fabiosoft

    Passenger

  • Members
  • 6 posts
  • LocationItaly

Posted 26 February 2014 - 06:36 PM

Hi, i'am making a project in Rails and i have all my big database model written in Mysql SQL language.

Can you advice me about using rails migrations or load entire database via phpmyadmin?

 

PS: I am a rails novice.

 

Thanks



#2 Norm

Norm

    Passenger

  • Members
  • 7 posts
  • LocationPrescott, AZ, USA

Posted 26 February 2014 - 07:16 PM

If this is a database used by other applications which you cannot change you have picked a very difficult path to follow in Rails.  It can be done but I would recommend it only for those who are experienced and familiar with Rails.  If it is just the database you have designed to address the problem it does not make much difference how you create it.  I would recommend you create a migration which would create the database because it makes it easier to modify and recreate when the time comes to change things and it can easily be put into a configuration control system.

 

You may imagine that you have captured the complete model but it will change.  For the easiest progress make sure the naming etc. corresponds to the normal Rails conventions.  Rails makes things easy when you follow the path.  Blazing your own trail is a lot of unnecessary work.



#3 fabiosoft

fabiosoft

    Passenger

  • Members
  • 6 posts
  • LocationItaly

Posted 26 February 2014 - 09:35 PM

Are you saying it's better to create all models? And if I need to change something? You know I think it's pretty useless create a bunch of migration in development...maybe in production it could have sense.
I don't know ...I am still learning. :)

#4 Norm

Norm

    Passenger

  • Members
  • 7 posts
  • LocationPrescott, AZ, USA

Posted 26 February 2014 - 10:22 PM   Best Answer

On my first project I just made up a sql script that I read via mysql to create the tables I needed.  I was urged by one more experienced to learn and use migrations.  I (after a while) made a big initial migration that defined everything I knew at that time and found that it was a lot easier to manage using migrations as long as I made sure they were reversable.  They work great in development (aren't you always in development?) and also in deployment.

 

Early in development if you change something you have a choice.  You can change the migration, blow away the whole db and migrate again or you can make a new migration that removes and adds and changes what you want and run that.  If you really want to keep your data that you have in the database a well crafted migration will do that.  If you do not need the data just start over on the db.

 

Your milage may vary.  I can only tell you what has worked for me and most practiced ROR users.



#5 fabiosoft

fabiosoft

    Passenger

  • Members
  • 6 posts
  • LocationItaly

Posted 26 February 2014 - 10:36 PM

Most practices ROR users... That's the answer I wanted to ear. I am a blank paper. I need the best way to learn this amazing framework.

Thanks

#6 Norm

Norm

    Passenger

  • Members
  • 7 posts
  • LocationPrescott, AZ, USA

Posted 26 February 2014 - 10:44 PM

The usual recommendation from those who are experienced is that a beginner should work through the tutorials at railstutorial.org (free to use online) to get a perspective on the system.  The other common recommendation is to use MacOS or Linux (I dual boot Linux and 7) either as a dual boot or VM.  Windows is a sub-par development environment for ROR.  I started my learning on ROR with 'Agile Web Development with Rails'.



#7 fabiosoft

fabiosoft

    Passenger

  • Members
  • 6 posts
  • LocationItaly

Posted 27 February 2014 - 09:18 PM

PS: I am a Mac OS/Linux user ;)



#8 Norm

Norm

    Passenger

  • Members
  • 7 posts
  • LocationPrescott, AZ, USA

Posted 28 February 2014 - 01:56 AM

Good to hear that.  Some people persist in trying to do things the hard way by developing ROR on a windows system and then complain.  I have been developing (not ROR) on Unix/Linux systems for about 35 years now so I believe Linux (or MacOS) is the way to go.



#9 fabiosoft

fabiosoft

    Passenger

  • Members
  • 6 posts
  • LocationItaly

Posted 01 March 2014 - 12:21 AM

Sorry for windows, but it's not made for business things.





Also tagged with one or more of these keywords: migrate, migration, database, sql

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users