diff --git a/core/Migrations/Version20170111103310.php b/core/Migrations/Version20170111103310.php new file mode 100644 index 000000000000..70c7811c0e98 --- /dev/null +++ b/core/Migrations/Version20170111103310.php @@ -0,0 +1,134 @@ +connection->getPrefix(); + if (!$schema->hasTable("${prefix}external_mounts")) { + $table = $schema->createTable("${prefix}external_mounts"); + $table->addColumn('mount_id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 20, + ]); + $table->addColumn('mount_point', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('storage_backend', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('auth_backend', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('priority', 'integer', [ + 'notnull' => true, + 'length' => 4, + 'default' => 100, + ]); + // admin = 1, personal = 2 + $table->addColumn('type', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + $table->setPrimaryKey(['mount_id']); + } + + if (!$schema->hasTable("${prefix}external_applicable")) { + $table = $schema->createTable("${prefix}external_applicable"); + $table->addColumn('applicable_id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 20, + ]); + // foreign key: external_mounts.mount_id + $table->addColumn('mount_id', 'bigint', [ + 'notnull' => true, + 'length' => 20, + ]); + // possible mount types: global = 1, group = 2, user = 3 + $table->addColumn('type', 'integer', [ + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('value', 'string', [ + 'notnull' => false, + 'length' => 64, + ]); + $table->setPrimaryKey(['applicable_id']); + $table->addIndex(['mount_id'], 'applicable_mount'); + $table->addIndex(['type', 'value'], 'applicable_type_value'); + $table->addUniqueIndex(['type', 'value', 'mount_id'], 'applicable_type_value_mount'); + } + + if (!$schema->hasTable("${prefix}external_config")) { + $table = $schema->createTable("${prefix}external_config"); + $table->addColumn('config_id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 20, + ]); + // foreign key: external_mounts.mount_id + $table->addColumn('mount_id', 'bigint', [ + 'notnull' => true, + 'length' => 20, + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('value', 'string', [ + 'notnull' => true, + 'length' => 4096, + ]); + $table->setPrimaryKey(['config_id']); + $table->addIndex(['mount_id'], 'config_mount'); + $table->addUniqueIndex(['mount_id', 'key'], 'config_mount_key'); + } + + if (!$schema->hasTable("${prefix}external_options")) { + $table = $schema->createTable("${prefix}external_options"); + $table->addColumn('option_id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 20, + ]); + // foreign key: external_mounts.mount_id + $table->addColumn('mount_id', 'bigint', [ + 'notnull' => true, + 'length' => 20, + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('value', 'string', [ + 'notnull' => true, + 'length' => 256, + ]); + $table->setPrimaryKey(['option_id']); + $table->addIndex(['mount_id'], 'option_mount'); + $table->addUniqueIndex(['mount_id', 'key'], 'option_mount_key'); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) { + // this down() migration is auto-generated, please modify it to your needs + + } +} diff --git a/db_structure.xml b/db_structure.xml index 40f51daa3b44..6b91c3c4c5d0 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -1884,225 +1884,4 @@ - - - *dbprefix*external_mounts - - - mount_id - integer - 0 - true - 1 - 6 - - - mount_point - text - 128 - true - - - storage_backend - text - 64 - true - - - auth_backend - text - 64 - true - - - priority - integer - 100 - 4 - true - - - - type - integer - 4 - true - - -
- - *dbprefix*external_applicable - - - applicable_id - integer - 0 - true - 1 - 6 - - - - mount_id - integer - true - 6 - - - - type - integer - 4 - true - - - - value - text - 64 - - - - applicable_mount - - mount_id - ascending - - - - applicable_type_value - - type - ascending - - - value - ascending - - - - applicable_type_value_mount - true - - type - ascending - - - value - ascending - - - mount_id - ascending - - - -
- - - *dbprefix*external_config - - - config_id - integer - 0 - true - 1 - 6 - - - - mount_id - integer - true - 6 - - - key - text - true - 64 - - - value - text - true - 4096 - - - - config_mount - - mount_id - ascending - - - - config_mount_key - true - - mount_id - ascending - - - key - ascending - - - -
- - - *dbprefix*external_options - - - option_id - integer - 0 - true - 1 - 6 - - - - mount_id - integer - true - 6 - - - key - text - true - 64 - - - value - text - true - 256 - - - - option_mount - - mount_id - ascending - - - - option_mount_key - true - - mount_id - ascending - - - key - ascending - - - -
- diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index ac98e5ed4870..c09915aad8b4 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -82,6 +82,10 @@ public function getDefaultConnectionParams($type) { \PDO::MYSQL_ATTR_FOUND_ROWS => true, ]; } + + // set default table creation options + $result['defaultTableOptions'] = ['collate' => 'utf8_bin']; + return $result; } diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index abcccb125c61..c4afd15f38ab 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -32,6 +32,7 @@ class MigrationService { * @param string $appName * @param IDBConnection $connection * @return Configuration + * @throws \Exception */ public function buildConfiguration($appName, $connection) { if ($appName === 'core') {