Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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.


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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (7)
    As of 2018-03-17 14:49 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (224 votes). Check out past polls.