Skip to content

Commit

Permalink
Alter some critical fields to BigInt
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Jul 12, 2017
1 parent bf286dd commit bf00edd
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 8 deletions.
32 changes: 32 additions & 0 deletions apps/dav/appinfo/Migrations/Version20170711193427.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace OCA\DAV\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OCP\Migration\ISchemaMigration;

/**
* Updates column type from integer to bigint
*/
class Version20170711193427 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];

if ($schema->hasTable("${prefix}properties")) {
$table = $schema->getTable("{$prefix}properties");

$idColumn = $table->getColumn('id');
if ($idColumn){
$idColumn->setType(Type::getType(Type::BIGINT));
$idColumn->setOptions(['length' => 20]);
}

$fileidColumn = $table->getColumn('fileid');
if ($fileidColumn){
$fileidColumn->setType(Type::getType(Type::BIGINT));
$fileidColumn->setOptions(['length' => 20]);
}
}
}
}
4 changes: 2 additions & 2 deletions apps/federatedfilesharing/appinfo/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ the servers (e.g. permissions change, unshare,...)
<name>share_id</name>
<type>integer</type>
<notnull>true</notnull>
<length>4</length>
<length>10</length>
</field>
<field>
<name>remote_id</name>
<type>integer</type>
<notnull>true</notnull>
<length>4</length>
<length>10</length>
<comments>share ID at the remote server</comments>
</field>
<index>
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/appinfo/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
<length>10</length>
</field>
<field>
<name>remote</name>
Expand All @@ -27,7 +27,7 @@
<type>integer</type>
<default>-1</default>
<notnull>true</notnull>
<length>4</length>
<length>10</length>
</field>
<field>
<name>share_token</name>
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/appinfo/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
<length>10</length>
</field>

<field>
Expand Down
26 changes: 26 additions & 0 deletions core/Migrations/Version20170711191432.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace OC\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OCP\Migration\ISchemaMigration;

/**
* Updates column type in the share table from integer to bigint
*/
class Version20170711191432 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];

if ($schema->hasTable("${prefix}share")) {
$table = $schema->getTable("{$prefix}share");

$fileSourceColumn = $table->getColumn('file_source');
if ($fileSourceColumn){
$fileSourceColumn->setType(Type::getType(Type::BIGINT));
$fileSourceColumn->setOptions(['length' => 20]);
}
}
}
}
7 changes: 4 additions & 3 deletions db_structure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<field>
<name>root_id</name>
<type>integer</type>
<length>10</length>
<notnull>true</notnull>
</field>

Expand Down Expand Up @@ -278,7 +279,7 @@
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
<length>10</length>
</field>

<!-- Foreign Key storages::numeric_id -->
Expand Down Expand Up @@ -312,7 +313,7 @@
<type>integer</type>
<default></default>
<notnull>true</notnull>
<length>4</length>
<length>10</length>
</field>

<field>
Expand Down Expand Up @@ -984,7 +985,7 @@
<default>0</default>
<notnull>true</notnull>
<unsigned>true</unsigned>
<length>4</length>
<length>10</length>
</field>

<!-- Foreign Key vcategory::id -->
Expand Down

0 comments on commit bf00edd

Please sign in to comment.