$bootstrapPath = rtrim($craftPath, '/') . '/app/bootstrap.php'; if (!file_exists($bootstrapPath)) { throw new Exception('Could not locale a Craft bootstrap file. Make sure that `$craftPath` is set correctly.'); } /** @var $app WebApp */ $app = (require $bootstrapPath); $database = $app->config->get('database', ConfigFile::Db); $tablePrefix = $app->config->get('tablePrefix', ConfigFile::Db); $version = $app->getVersion() . '.' . $app->getBuild(); if ($tablePrefix) { throw new Exception('This tool requires Craft to be configured without a DB table prefix.'); } $run = !empty($_POST['run']); if ($run) { $fks = array(); $tables = MigrationHelper::getTables(); foreach ($tables as $tableName => $table) { if ($table->fks) { foreach ($table->fks as $fk) { $fks[] = array($fk->table->name, implode(',', $fk->columns), $fk->refTable, implode(',', $fk->refColumns), $fk->onDelete, $fk->onUpdate, $fk->name); } } } $output = JsonHelper::encode($fks); if (!file_exists('fks')) { mkdir('fks'); } file_put_contents('fkdumps/' . $version . '.json', $output); } ?>