mirror of
https://github.com/nextcloud/server.git
synced 2026-02-27 18:37:17 +01:00
refactor(dbal): Migrate away from Type::getName
Instead use Type::lookupName Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
@@ -30,7 +30,7 @@ class Version1011Date20201120125158 extends SimpleMigrationStep {
|
||||
if ($schema->hasTable('federated_reshares')) {
|
||||
$table = $schema->getTable('federated_reshares');
|
||||
$remoteIdColumn = $table->getColumn('remote_id');
|
||||
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
|
||||
if ($remoteIdColumn && Type::lookupName($remoteIdColumn->getType()) !== Types::STRING) {
|
||||
$remoteIdColumn->setNotnull(false);
|
||||
$remoteIdColumn->setType(Type::getType(Types::STRING));
|
||||
$remoteIdColumn->setOptions(['length' => 255]);
|
||||
|
||||
@@ -88,7 +88,7 @@ class Version11300Date20201120141438 extends SimpleMigrationStep {
|
||||
} else {
|
||||
$table = $schema->getTable('share_external');
|
||||
$remoteIdColumn = $table->getColumn('remote_id');
|
||||
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
|
||||
if ($remoteIdColumn && Type::lookupName($remoteIdColumn->getType()) !== Types::STRING) {
|
||||
$remoteIdColumn->setNotnull(false);
|
||||
$remoteIdColumn->setType(Type::getType(Types::STRING));
|
||||
$remoteIdColumn->setOptions(['length' => 255]);
|
||||
|
||||
@@ -1268,11 +1268,6 @@
|
||||
<code><![CDATA[(int)$data['id']]]></code>
|
||||
</InvalidArgument>
|
||||
</file>
|
||||
<file src="apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getName]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/federatedfilesharing/lib/Notifications.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[sendNotification]]></code>
|
||||
@@ -1709,11 +1704,6 @@
|
||||
<code><![CDATA[getAppValue]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/files_sharing/lib/Migration/Version11300Date20201120141438.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getName]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="apps/files_sharing/lib/MountProvider.php">
|
||||
<InternalClass>
|
||||
<code><![CDATA[new View('/' . $parentShare->getShareOwner() . '/files')]]></code>
|
||||
@@ -3054,19 +3044,8 @@
|
||||
<code><![CDATA[$this->appConfig->getValues($app, false)]]></code>
|
||||
</FalsableReturnStatement>
|
||||
</file>
|
||||
<file src="core/Command/Db/AddMissingPrimaryKeys.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[hasPrimaryKey]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="core/Command/Db/ConvertFilecacheBigInt.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getName]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="core/Command/Db/ConvertType.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[getName]]></code>
|
||||
<code><![CDATA[getPrimaryKeyColumns]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidScalarArgument>
|
||||
|
||||
@@ -70,7 +70,7 @@ class ConvertFilecacheBigInt extends Command {
|
||||
$column = $table->getColumn($columnName);
|
||||
$isAutoIncrement = $column->getAutoincrement();
|
||||
$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
|
||||
if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
|
||||
if (Type::lookupName($column->getType()) !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
|
||||
$column->setType(Type::getType(Types::BIGINT));
|
||||
$column->setOptions(['length' => 20]);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace OC\Core\Command\Db;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Schema\AbstractAsset;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OC\DB\Connection;
|
||||
use OC\DB\ConnectionFactory;
|
||||
use OC\DB\MigrationService;
|
||||
@@ -379,7 +380,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
|
||||
return $this->columnTypes[$tableName][$columnName];
|
||||
}
|
||||
|
||||
$type = $table->getColumn($columnName)->getType()->getName();
|
||||
$type = Type::lookupName($table->getColumn($columnName)->getType());
|
||||
|
||||
switch ($type) {
|
||||
case Types::BLOB:
|
||||
|
||||
@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OC\App\InfoParser;
|
||||
use OC\Migration\SimpleOutput;
|
||||
use OCP\App\IAppManager;
|
||||
@@ -579,7 +580,7 @@ class MigrationService {
|
||||
|
||||
if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
|
||||
// Oracle doesn't support boolean column with non-null value
|
||||
if ($thing->getNotnull() && $thing->getType()->getName() === Types::BOOLEAN) {
|
||||
if ($thing->getNotnull() && Type::lookupName($thing->getType()) === Types::BOOLEAN) {
|
||||
$thing->setNotnull(false);
|
||||
}
|
||||
}
|
||||
@@ -591,8 +592,8 @@ class MigrationService {
|
||||
|
||||
// If the column was just created OR the length changed OR the type changed
|
||||
// we will NOT detect invalid length if the column is not modified
|
||||
if (($sourceColumn === null || $sourceColumn->getLength() !== $thing->getLength() || $sourceColumn->getType()->getName() !== Types::STRING)
|
||||
&& $thing->getLength() > 4000 && $thing->getType()->getName() === Types::STRING) {
|
||||
if (($sourceColumn === null || $sourceColumn->getLength() !== $thing->getLength() || Type::lookupName($sourceColumn->getType()) !== Types::STRING)
|
||||
&& $thing->getLength() > 4000 && Type::lookupName($thing->getType()) === Types::STRING) {
|
||||
throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is type String, but exceeding the 4.000 length limit.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class BigIntMigration extends SimpleMigrationStep {
|
||||
|
||||
foreach ($columns as $columnName) {
|
||||
$column = $table->getColumn($columnName);
|
||||
if ($column->getType()->getName() !== Types::BIGINT) {
|
||||
if (Type::lookupName($column->getType()) !== Types::BIGINT) {
|
||||
$column->setType(Type::getType(Types::BIGINT));
|
||||
$column->setOptions(['length' => 20]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user