Page 1 of 1
Default database SQL
Posted: Tue Jun 23, 2009 3:08 am
by dgoadby
For a new installation it would be nice if there was an installation SQL file with just the tables and records required to start off.
I have slowly stripped down the Sample system to create one and will freely submit it if required (is there a file section on the BB?).
Re: Default database SQL
Posted: Tue Jun 23, 2009 7:32 am
by steven
dgoadby,
We have a procedure (an activity) which should be in the next build, that strips all the debtor stuff out and leaves you with a 'vanilla' version.
(Sorry about that.)
This is the code for it...
//objects
$sql = "DELETE FROM zzsys_object ";
$sql .= "WHERE sys_setup <> '1' ";
nuRunQuery($sql);
//system objects
$sql = "DELETE FROM zzsys_form ";
$sql .= "WHERE sys_setup <> '1' ";
nuRunQuery($sql);
//delete browse records not needed
$sql = "DELETE FROM zzsys_browse ";
$sql .= "WHERE sbr_zzsys_form_id NOT IN (SELECT zzsys_form_id FROM zzsys_form) ";
nuRunQuery($sql);
// delete all activities
$sql = "DELETE FROM zzsys_activity ";
nuRunQuery($sql);
//delete all images
nuRunQuery("DELETE FROM zzsys_image WHERE sim_group <> 'System'");
// flush acces level permissions
nuRunQuery("TRUNCATE TABLE zzsys_access_level_activity");
nuRunQuery("TRUNCATE TABLE zzsys_access_level_object ");
nuRunQuery("TRUNCATE TABLE zzsys_access_level ");
//clean up stuff
nuRunQuery("TRUNCATE TABLE zzsys_library");
nuRunQuery("TRUNCATE TABLE zzsys_user_group");
nuRunQuery("TRUNCATE TABLE zzsys_user");
nuRunQuery("TRUNCATE TABLE zzsys_user_log");
nuRunQuery("TRUNCATE TABLE zzsys_variable");
nuRunQuery("TRUNCATE TABLE zzsys_trap");
nuRunQuery("TRUNCATE TABLE zzsys_report_log");
nuRunQuery("TRUNCATE TABLE zzsys_session");
//delete all other tables
$sql = "SHOW TABLES";
$tables = mysql_query($sql);
while($row = mysql_fetch_row($tables)) {
$tblname = $row[0];
if (false == ereg("^zzsys_",$tblname)) {
mysql_query("DROP TABLE $tblname");
}
}
//delete lists
$listList = array();
$sql = "SELECT * FROM zzsys_object WHERE sob_all_type = 'dropdown' ";
$rs = nuRunQuery($sql);
while($obj = mysql_fetch_object($rs)) {
if (ereg("zzsys_list",$obj->sob_dropdown_sql)) {
$result = explode("'",$obj->sob_dropdown_sql);
$listList[] = $result[1];
}
}
$listList = array_unique($listList);
$listList = implode("','", $listList);
$listList = "'".$listList."'";
nuRunQuery("DELETE FROM zzsys_list WHERE sli_name NOT IN ($listList)");
echo "done, please log out, and log back in again";
Re: Default database SQL
Posted: Wed Jun 24, 2009 4:39 am
by dgoadby
Thanks for that I will try it later today (UK time).
As I am still learning NuBuilder I might just strip out the SQL and run in directly.
Thanks
David