Commit ada8879e authored by Vincent Petry's avatar Vincent Petry Committed by GitHub

Merge pull request #27394 from owncloud/sharetable-migration

Move oc_share to migration
parents c4506b22 339a46e9
<?php
/**
* @author Vincent Petry <pvince81@owncloud.com>
*
* @copyright Copyright (c) 2017, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Migrations;
use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;
/**
* Initial DB creation for share table
*/
class Version20170315173825 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
if (!$schema->hasTable("${prefix}share")) {
$table = $schema->createTable("${prefix}share");
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
// Constant OCP\Share::SHARE_TYPE_*
$table->addColumn('share_type', 'smallint', [
'notnull' => true,
'default' => 0,
]);
// Foreign Key users::uid or NULL
$table->addColumn('share_with', 'string', [
'notnull' => false,
'length' => 255,
]);
// Foreign Key users::uid
// This is the owner of the share
// which does not have to be the initiator of the share -->
$table->addColumn('uid_owner', 'string', [
'default' => '',
'notnull' => true,
'length' => 64,
]);
// Foreign Key users::uid
// This is the initiator of the share
$table->addColumn('uid_initiator', 'string', [
'notnull' => false,
'length' => 64,
]);
// Foreign Key share:.id or NULL
$table->addColumn('parent', 'integer', [
'notnull' => false,
]);
// eg: "file" or "folder"
$table->addColumn('item_type', 'string', [
'default' => '',
'notnull' => true,
'length' => 64,
]);
// Foreign Key filecache::fileid
$table->addColumn('item_source', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('item_target', 'string', [
'notnull' => false,
'length' => 255,
]);
// Foreign Key filecache::fileid
$table->addColumn('file_source', 'integer', [
'notnull' => false,
]);
$table->addColumn('file_target', 'string', [
'notnull' => false,
'length' => 512,
]);
// Permission bitfield
$table->addColumn('permissions', 'smallint', [
'default' => 0,
'notnull' => true,
]);
// Time of share creation
$table->addColumn('stime', 'bigint', [
'default' => 0,
'notnull' => true,
]);
// Whether the receiver accepted the share, if share_with is set.
$table->addColumn('accepted', 'smallint', [
'default' => 0,
'notnull' => true,
]);
// Time of share expiration
$table->addColumn('expiration', 'datetime', [
'notnull' => false,
]);
// Public share token
$table->addColumn('token', 'string', [
'notnull' => false,
'length' => 32,
]);
$table->addColumn('mail_send', 'smallint', [
'default' => 0,
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
$table->addIndex(['file_source'], 'file_source_index');
$table->addIndex(['token'], 'token_index');
}
}
}
......@@ -680,195 +680,6 @@
</table>
<table>
<!--
Shares of all types (user-to-user, external-via-link, etc.)
-->
<name>*dbprefix*share</name>
<declaration>
<field>
<name>id</name>
<autoincrement>1</autoincrement>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>4</length>
</field>
<!-- Constant OCP\Share::SHARE_TYPE_* -->
<field>
<name>share_type</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>1</length>
</field>
<!-- Foreign Key users::uid or NULL -->
<field>
<name>share_with</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>255</length>
</field>
<!-- Foreign Key users::uid -->
<!-- This is the owner of the share
which does not have to be the initiator of the share -->
<field>
<name>uid_owner</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>64</length>
</field>
<!-- Foreign Key users::uid -->
<!-- This is the initiator of the share -->
<field>
<name>uid_initiator</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>64</length>
</field>
<!-- Foreign Key share::id or NULL -->
<field>
<name>parent</name>
<type>integer</type>
<notnull>false</notnull>
<length>4</length>
</field>
<!-- E.g. file or folder -->
<field>
<name>item_type</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>64</length>
</field>
<!-- Foreign Key filecache::fileid -->
<field>
<name>item_source</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>255</length>
</field>
<field>
<name>item_target</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>255</length>
</field>
<!-- Foreign Key filecache::fileid -->
<field>
<name>file_source</name>
<type>integer</type>
<notnull>false</notnull>
<length>4</length>
</field>
<field>
<name>file_target</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>512</length>
</field>
<!-- Permission bitfield -->
<field>
<name>permissions</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>1</length>
</field>
<!-- Time of share creation -->
<field>
<name>stime</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>8</length>
</field>
<!-- Whether the receiver accepted the share, if share_with is set. -->
<field>
<name>accepted</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>1</length>
</field>
<!-- Time of share expiration -->
<field>
<name>expiration</name>
<type>timestamp</type>
<default></default>
<notnull>false</notnull>
</field>
<field>
<name>token</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>32</length>
</field>
<field>
<name>mail_send</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>1</length>
</field>
<index>
<name>item_share_type_index</name>
<field>
<name>item_type</name>
<sorting>ascending</sorting>
</field>
<field>
<name>share_type</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>file_source_index</name>
<field>
<name>file_source</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>token_index</name>
<field>
<name>token</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
</table>
<table>
<!--
......
......@@ -25,7 +25,7 @@
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
$OC_Version = [10, 0, 0, 2];
$OC_Version = [10, 0, 0, 3];
// The human readable string
$OC_VersionString = '10.0.0 alpha';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment