Jump to content

[Windows/Linux] Combine SQL Updates


Gregarious

Recommended Posts

I made this batch initially for Trinity, but I'm here to convert it to Skyfire so it might be useful to someone else.

New Skyfire revisions will frequently come with new .sql updates in the \sql\updates directory that need to be imported in order to keep your DB up to date. This batch file will merge all of those .sql queries into 3 simple files:

  • All_Auth_Updates.sql
  • All_Characters_Updates.sql
  • All_World_Updates.sql
Combining numerous .sql files into only 3 will make importing these new updates much simpler. Also, this batch script will take into consideration the order in which new .sql updates need to be imported as well, judging by the file date and post-fix. Furthermore, I've included some formatting so that the single combined SQL file lists the file name before it outputs the SQL contents (click on the "Example output" links to see how it looks).

For Windows:

  • Copy/paste the below source into a new Notepad++ file and save it as "gather updates.bat" (without quotes of course, and whatever you'd like to call it)
  • Drop it into your main SkyFireEMU source directory.
  • After each Skyfire update that you do, double-click this .bat file to merge the new .SQL queries into 3 organized .SQL files to easily import them into your auth/characters/world databases.
Put this in your root SkyFireEMU folder:

 
@echo off
setlocal EnableDelayedExpansion
set WorldUpdates=All_World_Updates.sql
set CharactersUpdates=All_Characters_Updates.sql
set AuthUpdates=All_Auth_Updates.sql
 
if exist %CharactersUpdates% del %CharactersUpdates%
if exist %AuthUpdates% del %AuthUpdates%
if exist %WorldUpdates% del %WorldUpdates%
 
for %%a in (sql\updates\world\*.sql) do (
echo /* >>%WorldUpdates%
echo * %%a >>%WorldUpdates%
echo */ >>%WorldUpdates%
copy/b %WorldUpdates%+"%%a" %WorldUpdates%
echo. >>%WorldUpdates%
echo. >>%WorldUpdates%)
 
 
for %%a in (sql\updates\character\*.sql) do (
echo /* >>%CharactersUpdates%
echo * %%a >>%CharactersUpdates%
echo */ >>%CharactersUpdates%
copy/b %CharactersUpdates%+"%%a" %CharactersUpdates%
echo. >>%CharactersUpdates%
echo. >>%CharactersUpdates%)
 
 
for %%a in (sql\updates\auth\*.sql) do (
echo /* >>%AuthUpdates%
echo * %%a >>%AuthUpdates%
echo */ >>%AuthUpdates%
copy/b %AuthUpdates%+"%%a" %AuthUpdates%
echo. >>%AuthUpdates%
echo. >>%AuthUpdates%)
 

Example output

Alternate Method:

If you want to combine all the .sql files in any folder on your hard drive, put the below code into a batch file as explained above and toss it into the folder where all the .sql files are stored. It will grab every .sql file it sees (except for files in recursive directories - see code to change this option) and combine it into a "_MERGED.sql" file (the underscore ensures that the resulting file is at the top of a potentially long list of files). This also shows another method of formatting the text shown between each merged file, and you can pick which one you like best:

Put this in any folder with .sql files to merge them all:

@echo off
 
set filename=_MERGED.sql
 
if exist %filename% del %filename%
 
:: Replace the line below with: for /r %%a in (*.sql) do (
:: to also seek out and merge .sql files in nearby, recursive directories.
for %%a in (*.sql) do (
echo -- -------------------------------------------------------- >>%filename%
echo -- %%a >>%filename%
echo -- -------------------------------------------------------- >>%filename%
copy/b %filename%+"%%a" %filename%
echo. >>%filename%
echo. >>%filename%)

Example output

For Linux:

cd into your sql/updates directory and choose one of these options:

To combine all updates:

cat world/*.sql > all_world_updates.sql
cat characters/*.sql > all_characters_updates.sql

To combine all updates and immediately import them into your database (remember to use your own username, password, and database names):

for file in world/*.sql; do mysql -u USERNAME -pPASSWORD --database=world < $file; done
for file in characters/*.sql; do mysql -u USERNAME -pPASSWORD --database=characters < $file; done

Don't forget to √ Like This post if it helps!

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.