Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions appinfo/Migrations/Version20161209151129.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace OCA\CustomGroups\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20161209151129 extends AbstractMigration {
/**
* @param Schema $schema
*/
public function up(Schema $schema) {
$this->createGroupsTable($schema);
$this->createMembersTable($schema);
}

private function createGroupsTable(Schema $schema) {
$prefix = $this->connection->getPrefix();
$table = $schema->createTable("${prefix}custom_group");
$table->addColumn('group_id', 'integer', [
'autoincrement' => true,
'unsigned' => true,
'length' => 4,
]);
$table->addColumn('uri', 'string', [
'length' => 255,
'notnull' => true,
]);
$table->addColumn('display_name', 'string', [
'length' => 64,
'notnull' => true,
]);
// TODO: find how to set sort to ascending
$table->addUniqueIndex(['uri'], 'cg_uri_index');
$table->setPrimaryKey(['group_id']);
}

private function createMembersTable(Schema $schema) {
$prefix = $this->connection->getPrefix();
$table = $schema->createTable("${prefix}custom_group_member");
$table->addColumn('group_id', 'integer', [
'autoincrement' => true,
'unsigned' => true,
'length' => 4,
]);
$table->addColumn('user_id', 'string', [
'length' => 64,
'notnull' => true,
]);
$table->addColumn('is_admin', 'integer', [
'length' => 4,
'notnull' => true,
'default' => 0,
]);
$table->setPrimaryKey(['group_id', 'user_id']);
}

/**
* @param Schema $schema
*/
public function down(Schema $schema) {
$schema->dropTable('custom_group_member');
$schema->dropTable('custom_group');
}
}
21 changes: 21 additions & 0 deletions appinfo/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @author Vincent Petry <pvince81@owncloud.com>
*
* @copyright Copyright (c) 2016, 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/>
*
*/

1 change: 1 addition & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<types>
<authentication/>
</types>
<use-migrations>true</use-migrations>
<dependencies>
<owncloud min-version="9.2" max-version="9.2" />
</dependencies>
Expand Down