PDA

View Full Version : Need Help Packaging Mod - SQL tables install


EquinoxWorld
08-13-2011, 01:01 PM
Hello everyone, I am finally nearing the end of development of my first ever modification that I'll be releasing here at vb.org. (please be gentle when I do). In any case my concern at this stage is that I need to package the modification. Everything is pretty much packaged automatically with vb except I believe the SQL tables I created for the mod. Since this is my first mod I did not anticipate that I would have to have a record of the code used to create each table, to be honest some were created field by field as I went along. So now that I have to package this my question is would there be a "easy" way of getting the commands used to create them to insert them into my install script (I know that I can do this by going one by one and creating the code for each (not the most reliable way in my case))? I have over 10 db tables and I want to make sure that when someone installs the mod the tables are created correctly with the right index assigned and such. Would there be an automated way of doing this to ensure that the tables are created exactly the same as how I have them now? Also if possible if someone can also guide me as to how this table install codes should be placed within the install code of the product it would also be very helpful. If anyone can provide some information or guidance in this matter as to how to handle table creation with the product install code it would be very helpful.

Any info is good info. :D

Best Regards.

kh99
08-13-2011, 01:21 PM
If you use phpMyAdmin you can Export the table structure to SQL format. I'm not sure if there's a way to do that using the mysql command line programs.

EquinoxWorld
08-13-2011, 01:25 PM
If you use phpMyAdmin you can Export the table structure to SQL format. I'm not sure if there's a way to do that using the mysql command line programs.

Thanks for your reply kh99, I actually found this command that works rather well from the SQL command line:


SHOW CREATE TABLE tbl_name


I can use this to get the exact code used to create the tables. My question now is where should I place this code within the product install file? Also would there be a way of using this command to get more than one tables create codes at a time? I'm glad though that with this at least I get the exact command to get the table how it is right now. Now I just need to place it properly into the install code of the mod.

kh99
08-13-2011, 01:34 PM
What you really should do is have a test site in debug mode, by putting $config['Misc']['debug'] = 1; in include/config.php. Then you can go to Products & Plugins -> Manage Products in the adminCP, and "edit" the product. You'll then have text areas to put in install and uninstall code. When you've got the product the way you want it, you can export it to an xml file.

If you really want to do it by editing the product xml file, probably the best thing would be to find an existing product and see where to put xml tags for installcode and uninstallcode. It's a little complicated by the fact that you can have different sections of code for different versions, to support updating.

EquinoxWorld
08-13-2011, 01:46 PM
What you really should do is have a test site in debug mode, by putting $config['Misc']['debug'] = 1; in include/config.php. Then you can go to Products & Plugins -> Manage Products in the adminCP, and "edit" the product. You'll then have text areas to put in install and uninstall code. When you've got the product the way you want it, you can export it to an xml file.

If you really want to do it by editing the product xml file, probably the best thing would be to find an existing product and see where to put xml tags for installcode and uninstallcode. It's a little complicated by the fact that you can have different sections of code for different versions, to support updating.

Thanks for your reply kh, I actually have my site in debug already. I exported the product and am taking a look at the install code, everything is there except the SQL install/create commands. The install file is done except without the SQL commands to create the tables, my concern was how to add these to the already existing install product file. I am taking a look at some other mods to see how they did it but the method varies. I was wondering if anyone knew what was the best way or the "right" way of doing it.