Skip to content

Commit

Permalink
Remove legacy DB setup code (#2267)
Browse files Browse the repository at this point in the history
#1801, and subsequently,
#1948, removed legacy CDash 2.x
upgrade-related code. This PR removes the final scraps of legacy
database creation code left behind after those two PRs.
  • Loading branch information
williamjallen committed Jun 14, 2024
1 parent 8f4a288 commit c807a63
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 2,685 deletions.
40 changes: 0 additions & 40 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,46 +465,6 @@ public function install(): View
if ($db_created) {
Artisan::call('migrate --force');

// If we are with PostGreSQL we need to add some extra functions
if ($db_type == 'pgsql') {
$sqlfile = base_path('/app/cdash/sql/pgsql/cdash.ext.sql');

// Create the language. PgSQL has no way to know if the language already
// exists
@pdo_query('CREATE LANGUAGE plpgsql');

$file_content = file($sqlfile);
$query = '';
foreach ($file_content as $sql_line) {
$tsl = trim($sql_line);
if ($sql_line !== '' && !str_starts_with($tsl, '--')) {
$query .= $sql_line;
$possemicolon = strrpos($query, ';');
if ($possemicolon !== false && substr_count($query, '\'', 0, $possemicolon) % 2 == 0) {
// We need to remove only the last semicolon
$pos = strrpos($query, ';');
if ($pos !== false) {
$query = substr($query, 0, $pos) . substr($query, $pos + 1);
}
$result = pdo_query($query);
if (!$result) {
$xml .= '<db_created>0</db_created>';
abort(500, pdo_error());
}
$query = '';
}
}
}

// Check the version of PostgreSQL
$result_version = pdo_query('SELECT version()');
$version_array = pdo_fetch_array($result_version);
if (str_contains(strtolower($version_array[0]), 'postgresql 9.')) {
// For PgSQL 9.0 we need to set the bytea_output to 'escape' (it was changed to hexa)
@pdo_query("ALTER DATABASE {$db_name} SET bytea_output TO 'escape'");
}
}

$user = new \CDash\Model\User();
$user->Email = $admin_email;
$user->Password = password_hash($admin_password, PASSWORD_DEFAULT);
Expand Down
8 changes: 6 additions & 2 deletions app/cdash/app/Model/BuildUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use CDash\Database;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use PDO;

class BuildUpdate
Expand Down Expand Up @@ -404,8 +405,7 @@ public function FillFromBuildId(): bool
$stmt = $this->PDO->prepare(
"SELECT uf.* FROM updatefile uf
JOIN build2update b2u ON uf.updateid = b2u.updateid
WHERE b2u.buildid = ?
ORDER BY REVERSE(RIGHT(REVERSE(filename),LOCATE('/',REVERSE(filename))))");
WHERE b2u.buildid = ?");
pdo_execute($stmt, [$this->BuildId]);
while ($row = $stmt->fetch()) {
$file = new BuildUpdateFile();
Expand All @@ -423,6 +423,10 @@ public function FillFromBuildId(): bool
$this->AddFile($file);
}

usort($this->Files, function ($file1, $file2) {
return Str::afterLast('/', $file1->Filename) <=> Str::afterLast('/', $file2->Filename);
});

return true;
}

Expand Down
18 changes: 0 additions & 18 deletions app/cdash/sql/convert.sh

This file was deleted.

109 changes: 0 additions & 109 deletions app/cdash/sql/convert_alter_table.pl

This file was deleted.

Loading

0 comments on commit c807a63

Please sign in to comment.