Skip to content

Commit

Permalink
Merge pull request #28590 from owncloud/bigint-update-case
Browse files Browse the repository at this point in the history
Bigint update case
  • Loading branch information
VicDeo authored Aug 8, 2017
2 parents 7218375 + 0c0b61f commit 277496e
Show file tree
Hide file tree
Showing 17 changed files with 348 additions and 272 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace OCA\FederatedFileSharing\Migrations;
use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/** Creates initial schema */
class Version20170804201125 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
if (!$schema->hasTable("{$prefix}federated_reshares")) {
$table = $schema->createTable("{$prefix}federated_reshares");
$table->addColumn('share_id', 'bigint', [
'unsigned' => false,
'notnull' => true,
'length' => 11,
]);

$table->addColumn('remote_id', 'bigint', [
'unsigned' => false,
'notnull' => true,
'length' => 11,
'comment' => 'share ID at the remote server'
]);

$table->addUniqueIndex(
['share_id'],
'share_id_index'
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace OCA\FederatedFileSharing\Migrations;

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

/** Updates some fields to bigint if required */
class Version20170804201253 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];

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

$shareIdColumn = $table->getColumn('share_id');
if ($shareIdColumn && $shareIdColumn->getType()->getName() !== Type::BIGINT) {
$shareIdColumn->setType(Type::getType(Type::BIGINT));
$shareIdColumn->setOptions(['length' => 20]);
}

$remoteIdColumn = $table->getColumn('remote_id');
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::BIGINT) {
$remoteIdColumn->setType(Type::getType(Type::BIGINT));
$remoteIdColumn->setOptions(['length' => 20]);
}
}
}
}
41 changes: 0 additions & 41 deletions apps/federatedfilesharing/appinfo/database.xml

This file was deleted.

5 changes: 3 additions & 2 deletions apps/federatedfilesharing/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<description>Provide federated file sharing across ownCloud servers</description>
<licence>AGPL</licence>
<author>Bjoern Schiessle, Roeland Jago Douma</author>
<version>0.3.0</version>
<version>0.3.1</version>
<namespace>FederatedFileSharing</namespace>
<use-migrations>true</use-migrations>
<category>other</category>
<dependencies>
<owncloud min-version="10.0" max-version="10.0" />
<owncloud min-version="10.0.2.4" max-version="10.0" />
</dependencies>
<settings>
<admin>OCA\FederatedFileSharing\AdminPanel</admin>
Expand Down
94 changes: 94 additions & 0 deletions apps/files_sharing/appinfo/Migrations/Version20170804201125.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace OCA\Files_Sharing\Migrations;
use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/** Creates initial schema */
class Version20170804201125 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
if (!$schema->hasTable("{$prefix}share_external")) {
$table = $schema->createTable("{$prefix}share_external");
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'unsigned' => false,
'notnull' => true,
'length' => 11,
]);

$table->addColumn('remote', 'string', [
'notnull' => true,
'length' => 512,
'default' => null,
'comment' => 'Url of the remote owncloud instance'
]);

$table->addColumn('remote_id', 'bigint', [
'unsigned' => false,
'notnull' => true,
'default' => -1,
'length' => 11,
]);

$table->addColumn('share_token', 'string', [
'length' => 64,
'notnull' => true,
'comment' => 'Public share token'
]);

$table->addColumn('password', 'string', [
'length' => 64,
'notnull' => false,
'default' => null,
'comment' => 'Optional password for the public share'
]);

$table->addColumn('name', 'string', [
'length' => 64,
'notnull' => true,
'comment' => 'Original name on the remote server'
]);

$table->addColumn('owner', 'string', [
'length' => 64,
'notnull' => true,
'comment' => 'User that owns the public share on the remote server'
]);

$table->addColumn('user', 'string', [
'length' => 64,
'notnull' => true,
'comment' => 'Local user which added the external share'
]);

$table->addColumn('mountpoint', 'string', [
'length' => 4000,
'notnull' => true,
'comment' => 'Full path where the share is mounted'
]);

$table->addColumn('mountpoint_hash', 'string', [
'length' => 32,
'notnull' => true,
'comment' => 'md5 hash of the mountpoint'
]);

$table->addColumn('accepted', 'integer', [
'notnull' => true,
'default' => 0,
]);

$table->setPrimaryKey(['id']);

$table->addIndex(
['user'],
'sh_external_user'
);
$table->addUniqueIndex(
['user', 'mountpoint_hash'],
'sh_external_mp'
);
}
}
}
30 changes: 30 additions & 0 deletions apps/files_sharing/appinfo/Migrations/Version20170804201253.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace OCA\Files_Sharing\Migrations;

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

/** Updates some fields to bigint if required */
class Version20170804201253 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];

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

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

$remoteIdColumn = $table->getColumn('remote_id');
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::BIGINT) {
$remoteIdColumn->setType(Type::getType(Type::BIGINT));
$remoteIdColumn->setOptions(['length' => 20]);
}
}
}
}
2 changes: 1 addition & 1 deletion apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function() {
});

$config = \OC::$server->getConfig();
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
if (class_exists('OCA\Files\App') && $config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {

\OCA\Files\App::getNavigationManager()->add(function () {
$l = \OC::$server->getL10N('files_sharing');
Expand Down
109 changes: 0 additions & 109 deletions apps/files_sharing/appinfo/database.xml

This file was deleted.

5 changes: 3 additions & 2 deletions apps/files_sharing/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ Turning the feature off removes shared files and folders on the server for all s
<licence>AGPL</licence>
<author>Michael Gapczynski, Bjoern Schiessle</author>
<default_enable/>
<version>0.10.0</version>
<version>0.10.1</version>
<types>
<filesystem/>
</types>
<use-migrations>true</use-migrations>
<dependencies>
<owncloud min-version="10.0" max-version="10.0" />
<owncloud min-version="10.0.2.4" max-version="10.0" />
</dependencies>
<public>
<files>public.php</files>
Expand Down
Loading

0 comments on commit 277496e

Please sign in to comment.