Index: database/database.sql
===================================================================
--- database/database.sql	(revision 2577)
+++ database/database.sql	(working copy)
@@ -29,7 +29,7 @@
 --
 -- --------------------------------------------------------
 
-create database {DATABASE_NAME} CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+create database if not exists {DATABASE_NAME} CHARACTER SET utf8 COLLATE utf8_unicode_ci;
 
 use {DATABASE_NAME};
 
@@ -37,7 +37,7 @@
 -- Table structure for table `admin`
 --
 
-CREATE TABLE `admin` (
+CREATE TABLE IF NOT EXISTS `admin` (
   `admin_id` int(10) unsigned NOT NULL auto_increment,
   `admin_name` varchar(200) collate utf8_unicode_ci default NULL,
   `admin_pass` varchar(200) collate utf8_unicode_ci default NULL,
@@ -70,7 +70,7 @@
 -- Table structure for table `auto_num`
 --
 
-CREATE TABLE `auto_num` (
+CREATE TABLE IF NOT EXISTS `auto_num` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `msg` varchar(255) collate utf8_unicode_ci default NULL,
   UNIQUE KEY `id` (`id`)
@@ -82,7 +82,7 @@
 -- Table structure for table `config`
 --
 
-CREATE TABLE `config` (
+CREATE TABLE IF NOT EXISTS `config` (
   `name` varchar(255) collate utf8_unicode_ci NOT NULL default '',
   `value` varchar(255) collate utf8_unicode_ci NOT NULL default '',
   PRIMARY KEY  (`name`)
@@ -122,7 +122,7 @@
 -- Table structure for table `custom_menus`
 --
 
-CREATE TABLE `custom_menus` (
+CREATE TABLE IF NOT EXISTS `custom_menus` (
   `menu_id` int(10) unsigned NOT NULL auto_increment,
   `menu_level` varchar(10) collate utf8_unicode_ci default NULL,
   `menu_name` varchar(255) collate utf8_unicode_ci default NULL,
@@ -137,7 +137,7 @@
 -- Table structure for table `domain`
 --
 
-CREATE TABLE `domain` (
+CREATE TABLE IF NOT EXISTS `domain` (
   `domain_id` int(10) unsigned NOT NULL auto_increment,
   `domain_name` varchar(200) collate utf8_unicode_ci default NULL,
   `domain_gid` int(10) unsigned NOT NULL default '0',
@@ -173,7 +173,7 @@
 -- Table structure for table `domain_aliasses`
 --
 
-CREATE TABLE `domain_aliasses` (
+CREATE TABLE IF NOT EXISTS `domain_aliasses` (
   `alias_id` int(10) unsigned NOT NULL auto_increment,
   `domain_id` int(10) unsigned default NULL,
   `alias_name` varchar(200) collate utf8_unicode_ci default NULL,
@@ -190,7 +190,7 @@
 -- Table structure for table `domain_dns`
 --
 
-CREATE TABLE `domain_dns` (
+CREATE TABLE IF NOT EXISTS `domain_dns` (
   `domain_dns_id` int(11) NOT NULL auto_increment,
   `domain_id` int(11) NOT NULL,
   `alias_id` int(11) NOT NULL,
@@ -208,7 +208,7 @@
 -- Table structure for table `domain_traffic`
 --
 
-CREATE TABLE `domain_traffic` (
+CREATE TABLE IF NOT EXISTS `domain_traffic` (
   `dtraff_id` int(10) unsigned NOT NULL auto_increment,
   `domain_id` int(10) unsigned default NULL,
   `dtraff_time` bigint(20) unsigned default NULL,
@@ -229,7 +229,7 @@
 -- Table structure for table `email_tpls`
 --
 
-CREATE TABLE `email_tpls` (
+CREATE TABLE IF NOT EXISTS `email_tpls` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `owner_id` int(10) unsigned NOT NULL default '0',
   `name` varchar(200) collate utf8_unicode_ci default NULL,
@@ -244,7 +244,7 @@
 -- Table structure for table `error_pages`
 --
 
-CREATE TABLE `error_pages` (
+CREATE TABLE IF NOT EXISTS `error_pages` (
   `ep_id` int(10) unsigned NOT NULL auto_increment,
   `user_id` int(10) unsigned NOT NULL default '0',
   `error_401` text collate utf8_unicode_ci NOT NULL,
@@ -260,7 +260,7 @@
 -- Table structure for table `ftp_group`
 --
 
-CREATE TABLE `ftp_group` (
+CREATE TABLE IF NOT EXISTS `ftp_group` (
   `groupname` varchar(255) collate utf8_unicode_ci default NULL,
   `gid` int(10) unsigned NOT NULL default '0',
   `members` text collate utf8_unicode_ci,
@@ -273,7 +273,7 @@
 -- Table structure for table `ftp_users`
 --
 
-CREATE TABLE `ftp_users` (
+CREATE TABLE IF NOT EXISTS `ftp_users` (
   `userid` varchar(255) collate utf8_unicode_ci default NULL,
   `passwd` varchar(255) collate utf8_unicode_ci default NULL,
   `uid` int(10) unsigned NOT NULL default '0',
@@ -289,7 +289,7 @@
 -- Table structure for table `hosting_plans`
 --
 
-CREATE TABLE `hosting_plans` (
+CREATE TABLE IF NOT EXISTS `hosting_plans` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `reseller_id` int(10) unsigned NOT NULL default '0',
   `name` varchar(255) collate utf8_unicode_ci default NULL,
@@ -309,7 +309,7 @@
 -- Table structure for table `htaccess`
 --
 
-CREATE TABLE `htaccess` (
+CREATE TABLE IF NOT EXISTS `htaccess` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `dmn_id` int(10) unsigned NOT NULL default '0',
   `user_id` varchar(255) collate utf8_unicode_ci default NULL,
@@ -327,7 +327,7 @@
 -- Table structure for table `htaccess_groups`
 --
 
-CREATE TABLE `htaccess_groups` (
+CREATE TABLE IF NOT EXISTS `htaccess_groups` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `dmn_id` int(10) unsigned NOT NULL default '0',
   `ugroup` varchar(255) collate utf8_unicode_ci default NULL,
@@ -342,7 +342,7 @@
 -- Table structure for table `htaccess_users`
 --
 
-CREATE TABLE `htaccess_users` (
+CREATE TABLE IF NOT EXISTS `htaccess_users` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `dmn_id` int(10) unsigned NOT NULL default '0',
   `uname` varchar(255) collate utf8_unicode_ci default NULL,
@@ -357,7 +357,7 @@
 -- Table structure for table `log`
 --
 
-CREATE TABLE `log` (
+CREATE TABLE IF NOT EXISTS `log` (
   `log_id` int(10) unsigned NOT NULL auto_increment,
   `log_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   `log_message` varchar(250) collate utf8_unicode_ci default NULL,
@@ -370,7 +370,7 @@
 -- Table structure for table `login`
 --
 
-CREATE TABLE `login` (
+CREATE TABLE IF NOT EXISTS `login` (
   `session_id` varchar(200) collate utf8_unicode_ci NOT NULL default '',
   `ipaddr` varchar(15) collate utf8_unicode_ci default NULL,
   `lastaccess` int(10) unsigned default NULL,
@@ -386,7 +386,7 @@
 -- Table structure for table `mail_users`
 --
 
-CREATE TABLE `mail_users` (
+CREATE TABLE IF NOT EXISTS `mail_users` (
   `mail_id` int(10) unsigned NOT NULL auto_increment,
   `mail_acc` varchar(200) collate utf8_unicode_ci default NULL,
   `mail_pass` varchar(150) collate utf8_unicode_ci default NULL,
@@ -408,7 +408,7 @@
 -- Table structure for table `orders`
 --
 
-CREATE TABLE `orders` (
+CREATE TABLE IF NOT EXISTS `orders` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `user_id` int(10) unsigned NOT NULL default '0',
   `plan_id` int(10) unsigned NOT NULL default '0',
@@ -438,7 +438,7 @@
 -- Table structure for table `orders_settings`
 --
 
-CREATE TABLE `orders_settings` (
+CREATE TABLE IF NOT EXISTS `orders_settings` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `user_id` int(10) unsigned NOT NULL default '0',
   `header` text collate utf8_unicode_ci,
@@ -452,7 +452,7 @@
 -- Table structure for table `quotalimits`
 --
 
-CREATE TABLE `quotalimits` (
+CREATE TABLE IF NOT EXISTS `quotalimits` (
   `name` varchar(30) collate utf8_unicode_ci NOT NULL default '',
   `quota_type` enum('user','group','class','all') collate utf8_unicode_ci NOT NULL default 'user',
   `per_session` enum('false','true') collate utf8_unicode_ci NOT NULL default 'false',
@@ -472,7 +472,7 @@
 -- Table structure for table `quotatallies`
 --
 
-CREATE TABLE `quotatallies` (
+CREATE TABLE IF NOT EXISTS `quotatallies` (
   `name` varchar(30) collate utf8_unicode_ci NOT NULL default '',
   `quota_type` enum('user','group','class','all') collate utf8_unicode_ci NOT NULL default 'user',
   `bytes_in_used` float NOT NULL default '0',
@@ -490,7 +490,7 @@
 -- Table structure for table `reseller_props`
 --
 
-CREATE TABLE `reseller_props` (
+CREATE TABLE IF NOT EXISTS `reseller_props` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `reseller_id` int(10) unsigned NOT NULL default '0',
   `current_dmn_cnt` int(11) default NULL,
@@ -523,7 +523,7 @@
 -- Table structure for table `server_ips`
 --
 
-CREATE TABLE `server_ips` (
+CREATE TABLE IF NOT EXISTS `server_ips` (
   `ip_id` int(10) unsigned NOT NULL auto_increment,
   `ip_number` varchar(15) collate utf8_unicode_ci default NULL,
   `ip_domain` varchar(200) collate utf8_unicode_ci default NULL,
@@ -540,7 +540,7 @@
 -- Table structure for table `server_traffic`
 --
 
-CREATE TABLE `server_traffic` (
+CREATE TABLE IF NOT EXISTS `server_traffic` (
   `straff_id` int(10) unsigned NOT NULL auto_increment,
   `traff_time` int(10) unsigned default NULL,
   `bytes_in` bigint(20) unsigned default NULL,
@@ -563,7 +563,7 @@
 -- Table structure for table `sql_database`
 --
 
-CREATE TABLE `sql_database` (
+CREATE TABLE IF NOT EXISTS `sql_database` (
   `sqld_id` int(10) unsigned NOT NULL auto_increment,
   `domain_id` int(10) unsigned default '0',
   `sqld_name` varchar(64) character set utf8 collate utf8_bin default 'n/a',
@@ -576,7 +576,7 @@
 -- Table structure for table `sql_user`
 --
 
-CREATE TABLE `sql_user` (
+CREATE TABLE IF NOT EXISTS `sql_user` (
   `sqlu_id` int(10) unsigned NOT NULL auto_increment,
   `sqld_id` int(10) unsigned default '0',
   `sqlu_name` varchar(64) collate utf8_unicode_ci default 'n/a',
@@ -590,7 +590,7 @@
 -- Table structure for table `straff_settings`
 --
 
-CREATE TABLE `straff_settings` (
+CREATE TABLE IF NOT EXISTS `straff_settings` (
   `straff_max` int(10) unsigned default NULL,
   `straff_warn` int(10) unsigned default NULL,
   `straff_email` int(10) unsigned default NULL
@@ -608,7 +608,7 @@
 -- Table structure for table `subdomain`
 --
 
-CREATE TABLE `subdomain` (
+CREATE TABLE IF NOT EXISTS `subdomain` (
   `subdomain_id` int(10) unsigned NOT NULL auto_increment,
   `domain_id` int(10) unsigned default NULL,
   `subdomain_name` varchar(200) collate utf8_unicode_ci default NULL,
@@ -623,7 +623,7 @@
 -- Table structure for table `subdomain_alias`
 --
 
-CREATE TABLE `subdomain_alias` (
+CREATE TABLE IF NOT EXISTS `subdomain_alias` (
   `subdomain_alias_id` int(10) unsigned NOT NULL auto_increment,
   `alias_id` int(10) unsigned default NULL,
   `subdomain_alias_name` varchar(200) collate utf8_unicode_ci default NULL,
@@ -638,7 +638,7 @@
 -- Table structure for table `suexec_props`
 --
 
-CREATE TABLE `suexec_props` (
+CREATE TABLE IF NOT EXISTS `suexec_props` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `uid` int(10) unsigned default NULL,
   `gid` int(10) unsigned default NULL,
@@ -653,7 +653,7 @@
 -- Table structure for table `tickets`
 --
 
-CREATE TABLE `tickets` (
+CREATE TABLE IF NOT EXISTS `tickets` (
   `ticket_id` int(10) unsigned NOT NULL auto_increment,
   `ticket_level` int(10) default NULL,
   `ticket_from` int(10) unsigned default NULL,
@@ -673,7 +673,7 @@
 -- Table structure for table `user_gui_props`
 --
 
-CREATE TABLE `user_gui_props` (
+CREATE TABLE IF NOT EXISTS `user_gui_props` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `user_id` int(10) unsigned NOT NULL default '0',
   `lang` varchar(255) collate utf8_unicode_ci default '',
