Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

This is how I do it:

  1. Create a table called version in each database, containing only one integer field named version. This table will only ever hold one row containing its version.
  2. Create an sql directory in the source directory tree. This table holds sql files with names like 0.sql, 1.sql, 2.sql, etc. All those files contain valid sql statements to create table, drop table, create column, updates, etc. The file names must be sequentially created. The 0.sql contains the initial schema (usually the output of mysqldump without the data). The other *.sql files usually contain various database modification statements.
  3. Create a script that checks the latest version of the database and applies each sql files with the number higher than the version. Update the version table after applying each sql file.

I actually have the script but it still contains my company's specific code in it. If you don't mind playing around with it to make it work in your situation, I probably can send it to you upon request.

This is basically a primitive database versioning system. I recently added a hook functionality into it, which will be automatically called before or after applying an sql file. If I have time, I'd like to submit it to CPAN. But that's quite a big 'if' considering my current workload.

Hope that helps.

-cheepy-

In reply to Re: Generating ALTER TABLE code for MySQL by badaiaqrandista
in thread Generating ALTER TABLE code for MySQL by blogical

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (11)
    As of 2014-09-22 17:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (198 votes), past polls