mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-26 22:14:18 +01:00
Database import tables on every install with "IF NOT EXISTS"
This fixed errors when one table is missing or is duplicated
This commit is contained in:
@@ -30,26 +30,22 @@ if(!$error) {
|
||||
}
|
||||
}
|
||||
|
||||
if($db->hasTable(TABLE_PREFIX . 'account_actions')) {
|
||||
$locale['step_database_error_table_exist'] = str_replace('$TABLE$', TABLE_PREFIX . 'account_actions', $locale['step_database_error_table_exist']);
|
||||
warning($locale['step_database_error_table_exist']);
|
||||
}
|
||||
else {
|
||||
// import schema
|
||||
try {
|
||||
$locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']);
|
||||
success($locale['step_database_importing']);
|
||||
// import schema
|
||||
try {
|
||||
$locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']);
|
||||
success($locale['step_database_importing']);
|
||||
|
||||
$db->exec(file_get_contents(BASE . 'install/includes/schema.sql'));
|
||||
$db->exec(file_get_contents(BASE . 'install/includes/schema.sql'));
|
||||
|
||||
$locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']);
|
||||
success($locale['step_database_success_schema']);
|
||||
}
|
||||
catch(PDOException $error_) {
|
||||
error($locale['step_database_error_schema'] . ' ' . $error_);
|
||||
return;
|
||||
}
|
||||
$locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']);
|
||||
success($locale['step_database_success_schema']);
|
||||
}
|
||||
catch(PDOException $error_) {
|
||||
error($locale['step_database_error_schema'] . ' ' . $error_);
|
||||
return;
|
||||
}
|
||||
|
||||
require BASE . 'install/includes/import_base_data.php';
|
||||
|
||||
if(!$db->hasColumn('accounts', 'email')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email` varchar(255) NOT NULL DEFAULT '';"))
|
||||
|
||||
Reference in New Issue
Block a user