Jump to content

mangos sql update generator

Recommended Posts

This is a perl script that creates a combined file a for all updates between the specified interval (one for each db), so you don't have to apply them one by one:

use strict;

my $desc = "Generates a combined SQL file with all MaNGOS updates between specified revisions.";
my $usage = "Usage: $0 <first_rev> <last_rev>";
die "$desc\\n\\n$usage\\n" if $#ARGV != 1;

my $first_rev = int($ARGV[0]);
my $last_rev = int($ARGV[1]);
die "error: Invalid parameters.\\n\\n$usage\\n" if $first_rev == 0 || $last_rev == 0;

sub generate
   my ($filename, @file_list) = @_;
   print "generating $filename\\n";
   open(FOUT, ">$filename");
   foreach my $srcfile (@file_list)
       if ($srcfile =~ m/^(\\d+)/)
           if ($1 >= $first_rev && $1 <= $last_rev)
               print "-- adding $srcfile\\n";
               open(FIN, "<$srcfile");
               print FOUT "-- [ $srcfile ] --\\n";
               print FOUT <FIN>;
               print FOUT "\\n";
   print "\\n";

my $rev_interval = "$first_rev-$last_rev";

&generate("mangos_WORLD_$rev_interval.sql", glob "*_mangos_*.sql");
&generate("mangos_CHAR_$rev_interval.sql", glob "*_characters_*.sql");
&generate("mangos_REALM_$rev_interval.sql", glob "*_realmd_*.sql");

Link to comment
Share on other sites

Something as simple as below does the job.

This is another way to update the world db, the same script can be cloned to update the char db.


MYSQL="$(which mysql)"

for i in *mangos*.sql
   echo "--- Update $i"
   $MYSQL -u$DBU -p$DBP -D $DBWORLD < $i

Link to comment
Share on other sites

  • 1 month later...

Question regarding this topic.

What if I put all the necessary update SQL files in one folder, and do "cat *.sql" to concatenate them into one big SQL file?

It worked fine until a few months ago. Yeah, it's a very primitive way of doing it though.


Link to comment
Share on other sites

Not all sql updates safe apply without reading notes. Some weeks ago have some that specially notes check DB name compatibility before apply.

So you anyway need read related commit notes before apply sql update

Yes that's true, for example sometimes the databse name is hardly coded in the script, if you have changed the default db names you can run in deep trauma...

Link to comment
Share on other sites

When you do that, maybe you could add a suffix such as "11293_mangos_command_WARNING.sql" or something you want. Do the sql updates need to have exactly the same file name form?

Yes something like that will permit to handle special cases and also to automate the updates.

Link to comment
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use