mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Order table creation by foreign key dependency
This commit is contained in:
parent
72132b2e74
commit
a9821b815d
2 changed files with 77 additions and 2 deletions
|
|
@ -530,7 +530,7 @@ class installController extends install
|
|||
// Create a table if the schema xml exists in the "schemas" directory of the module
|
||||
$schema_dir = sprintf('%s/schemas/', $module_path);
|
||||
$schema_files = FileHandler::readDir($schema_dir, NULL, false, true);
|
||||
|
||||
$schema_sorted = [];
|
||||
foreach ($schema_files as $filename)
|
||||
{
|
||||
if (!preg_match('/\/([a-zA-Z0-9_]+)\.xml$/', $filename, $matches))
|
||||
|
|
@ -543,16 +543,24 @@ class installController extends install
|
|||
}
|
||||
|
||||
$table_name = $matches[1];
|
||||
if($oDB->isTableExists($table_name))
|
||||
if(isset($schema_sorted[$table_name]) || $oDB->isTableExists($table_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$schema_sorted[$table_name] = $filename;
|
||||
}
|
||||
|
||||
$schema_sorted = Rhymix\Framework\Parsers\DBTableParser::resolveDependency($schema_sorted);
|
||||
foreach ($schema_sorted as $table_name => $filename)
|
||||
{
|
||||
$output = $oDB->createTable($filename);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
throw new Exception(lang('msg_create_table_failed') . ': ' . $table_name . ': ' . $oDB->getError()->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Create a table and module instance and then execute install() method
|
||||
unset($oModule);
|
||||
$oModule = ModuleModel::getModuleInstallClass($module);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue