Skip to content

Commit ff5305b

Browse files
committed
fix: oracle migration
1 parent d6a4468 commit ff5305b

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

lib/private/DB/Migrator.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public function generateChangeScript(Schema $targetSchema) {
9797
return $script;
9898
}
9999

100+
public function filterSchemaAsset($asset): bool {
101+
if ($asset instanceof AbstractAsset) {
102+
$asset = $asset->getName();
103+
}
104+
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
105+
return str_starts_with($asset, $prefix);
106+
}
107+
100108
/**
101109
* Create a unique name for the temporary table
102110
*
@@ -108,12 +116,8 @@ protected function generateTemporaryTableName($name) {
108116
}
109117

110118
public function createSchema() {
111-
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
112-
$this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) use ($prefix) {
113-
if ($asset instanceof AbstractAsset) {
114-
$asset = $asset->getName();
115-
}
116-
return str_starts_with($asset, $prefix);
119+
$this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) {
120+
return $this->filterSchemaAsset($asset);
117121
});
118122
return $this->connection->getSchemaManager()->createSchema();
119123
}
@@ -137,12 +141,8 @@ protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $conn
137141
}
138142
}
139143

140-
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
141-
$this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) use ($prefix) {
142-
if ($asset instanceof AbstractAsset) {
143-
$asset = $asset->getName();
144-
}
145-
return str_starts_with($asset, $prefix);
144+
$this->connection->getConfiguration()->setSchemaAssetsFilter(function ($asset) {
145+
return $this->filterSchemaAsset($asset);
146146
});
147147
$sourceSchema = $connection->getSchemaManager()->createSchema();
148148

lib/private/DB/OracleMigrator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace OC\DB;
2525

26+
use Doctrine\DBAL\Schema\AbstractAsset;
2627
use Doctrine\DBAL\Schema\Column;
2728
use Doctrine\DBAL\Schema\ColumnDiff;
2829
use Doctrine\DBAL\Schema\Index;
@@ -215,4 +216,12 @@ protected function convertStatementToScript($statement) {
215216
$script .= PHP_EOL;
216217
return $script;
217218
}
219+
220+
public function filterSchemaAsset($asset): bool {
221+
if ($asset instanceof AbstractAsset) {
222+
$asset = $asset->getName();
223+
}
224+
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
225+
return str_starts_with($asset, "\"$prefix");
226+
}
218227
}

lib/private/Setup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,16 @@ public function install($options) {
350350
// apply necessary migrations
351351
$dbSetup->runMigrations();
352352
} catch (\OC\DatabaseSetupException $e) {
353+
$this->logger->logException($e);
353354
$error[] = [
354355
'error' => $e->getMessage(),
355356
'hint' => $e->getHint()
356357
];
357358
return($error);
358359
} catch (Exception $e) {
360+
$this->logger->logException($e);
359361
$error[] = [
360-
'error' => 'Error while trying to create admin user: ' . $e->getMessage(),
362+
'error' => 'Error while trying to setup the dabase: ' . $e->getMessage(),
361363
'hint' => $e->getTraceAsString()
362364
];
363365
return($error);

0 commit comments

Comments
 (0)