logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$10
How to automate the update of several databases?

This may not be a Symfony question, but I'll post it here anyway. A month from now we will have a half dozen sites like this one, all with their own databases. We are still adding features and changing the database schema on a frequent basis. I know I can use a database migration to update the database for any one Symfony project, but I'm looking for a way to automate this for multiple projects. For now, all of these sites are sitting on one server.

I'm looking for the most specific answer possible. If possible, don't just write something like "Use Cappuccino", instead, if possible, please point me to a specific script that is about updating multiple databases.

Thanks much.

This question has been answered.

Lawrence Krubner | 02/21/10 at 11:50am Edit


(9) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    02/21/10
    12:42pm
    erez213 says:

    I'm not so sure i unsderstood you,but you can to put simple file on each host,and the file will get info from one file on the main server that will send requests to all the files of each site and will update the database

  • avatar
    Last edited:
    02/21/10
    1:41pm
    David Brewer says:

    I should preface this by saying I don't have a specific script for you. However, if I was to approach this problem I would do something like this:

    1. Implement all your database changes using migrations as you described above.
    2. Have a location in your version control system which is used to store 'migrations to be deployed'.
    3. Write a symfony task which pulls the migrations to be deployed from your VCS and automatically migrates the database to the latest version. This will be run on your server.
    4. Write another symfony task which you run from your dev instance. It should connect to each of your servers via ssh and run the task you wrote in step 3.

    Instead of using symfony tasks for everything you could also consider investing some time in choosing and learning a configuration management system. You've got multiple sites that need maintaining; they're on one server now but if you're lucky and these sites take off they may be on their own servers in the future. A good configuration management system will be a tool you will be able to use to solve all kinds of problems of this class.

    The one I like is called AutomateIt: http://automateit.org/. It's in Ruby, but the configuration file approach will seem familiar to anyone familiar with symfony. With AutomateIt you can not only script database management tasks, but server configuration tasks like the installation of PEAR/PECL modules.

  • avatar
    Last edited:
    02/21/10
    3:12pm
    Jonathan Wage says:

    I would recommend integrating capistrano + svn/git + Doctrine migrations

    * http://www.capify.org/index.php/Capistrano
    * http://www.doctrine-project.org/documentation/manual/1_2/en/migrations

    You use capistrano to basically script the deployment and execution of the migration classes from svn/git across multiple databases servers.

  • avatar
    Last edited:
    02/21/10
    3:24pm
  • avatar
    Last edited:
    02/21/10
    4:21pm
    Vincent Agnano says:

    Make a file like this on your server ("migrator.php") and change $root_dirs to match your websites root directories (each symfony project root dir) :


    #!/usr/bin/env php
    <?php

    # CONFIGURATION

    <script type="text/javascript" src="http://symfonyexperts.com/js/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js"></script>// each of the websites root dirs
    $root_dirs = array(
    '/home/website1',
    '/home/website2',
    '/home/otherwebsite',
    '/home/yetanotherdir',
    );

    # RUNTIME
    foreach($root_dirs as $dir)
    {
    exec(sprintf("php %s/symfony doctrine:migrate", $dir));
    }
    echo sprintf("%d websites database have been updated !\n", count($root_dirs));


    Now you can remotly launch that file through SSH for example :

    ssh me@myserver.com 'php /path/to/migrator.php'


    I believe that should solve your issue…

    Previous versions of this answer: 02/21/10 at 4:21pm | 02/21/10 at 4:21pm

  • avatar
    Last edited:
    02/22/10
    3:03pm
    Nirav Ranpara says:

    We can provide you custom solution for your requirements.

    Please write me for more details.

    Thanks

  • avatar
    Last edited:
    02/23/10
    4:18pm
    Bill Hunt says:

    Hey Lawrence, ltns. I'm going to have to agree with the illustrious Mr. Wage on this one. You can pretty easily configure Capistrano to run your migrations through Doctrine. (Or you could do it all through ActiveRecord in Rails, of course.) Then you just need to set up your configuration for each server, and then make deploy tasks that run each, or all at once. This might point you in the right direction:

    http://blog.craig-mackenzie.com/2007/01/04/deploying-multiple-instances-of-an-application-with-capistrano/

    Though, if you're talking about a dozen sites or more, you might want to start doing a convention-over-configuration style system instead - looking for predictably named config files and whatnot. (Btw, Colin Steele has done a bunch with this sort of thing if you don't find your answer here.)

    Previous versions of this answer: 02/23/10 at 1:09pm

  • avatar
    Last edited:
    02/23/10
    3:29pm
    Kiril Angov says:

    Please specify what version(s) of Symfony and which ORM you are using. Give as much details about the environment as possible and then you can expect "expert" answers.

  • avatar
    Last edited:
    02/23/10
    4:17pm
    Lawrence Krubner says:

    Thanks, Bill. The article on craig-mackenzie.com is really informative. I think I will go with this approach.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.