123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- declare(strict_types=1);
- namespace OCA\Files_External\Migration;
- use Closure;
- use OCP\DB\ISchemaWrapper;
- use OCP\DB\Types;
- use OCP\Migration\IOutput;
- use OCP\Migration\SimpleMigrationStep;
- class Version1011Date20200630192246 extends SimpleMigrationStep {
-
- public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
-
- $schema = $schemaClosure();
- if (!$schema->hasTable('external_mounts')) {
- $table = $schema->createTable('external_mounts');
- $table->addColumn('mount_id', Types::BIGINT, [
- 'autoincrement' => true,
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('mount_point', Types::STRING, [
- 'notnull' => true,
- 'length' => 128,
- ]);
- $table->addColumn('storage_backend', Types::STRING, [
- 'notnull' => true,
- 'length' => 64,
- ]);
- $table->addColumn('auth_backend', Types::STRING, [
- 'notnull' => true,
- 'length' => 64,
- ]);
- $table->addColumn('priority', Types::INTEGER, [
- 'notnull' => true,
- 'length' => 4,
- 'default' => 100,
- ]);
- $table->addColumn('type', Types::INTEGER, [
- 'notnull' => true,
- 'length' => 4,
- ]);
- $table->setPrimaryKey(['mount_id']);
- }
- if (!$schema->hasTable('external_applicable')) {
- $table = $schema->createTable('external_applicable');
- $table->addColumn('applicable_id', Types::BIGINT, [
- 'autoincrement' => true,
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('mount_id', Types::BIGINT, [
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('type', Types::INTEGER, [
- 'notnull' => true,
- 'length' => 4,
- ]);
- $table->addColumn('value', Types::STRING, [
- 'notnull' => false,
- 'length' => 64,
- ]);
- $table->setPrimaryKey(['applicable_id']);
- $table->addIndex(['mount_id'], 'applicable_mount');
- $table->addUniqueIndex(['type', 'value', 'mount_id'], 'applicable_type_value_mount');
- }
- if (!$schema->hasTable('external_config')) {
- $table = $schema->createTable('external_config');
- $table->addColumn('config_id', Types::BIGINT, [
- 'autoincrement' => true,
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('mount_id', Types::BIGINT, [
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('key', Types::STRING, [
- 'notnull' => true,
- 'length' => 64,
- ]);
- $table->addColumn('value', Types::STRING, [
- 'notnull' => false,
- 'length' => 4000,
- ]);
- $table->setPrimaryKey(['config_id']);
- $table->addUniqueIndex(['mount_id', 'key'], 'config_mount_key');
- } else {
- $table = $schema->getTable('external_config');
- $table->changeColumn('value', [
- 'notnull' => false,
- 'length' => 4000,
- ]);
- }
- if (!$schema->hasTable('external_options')) {
- $table = $schema->createTable('external_options');
- $table->addColumn('option_id', Types::BIGINT, [
- 'autoincrement' => true,
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('mount_id', Types::BIGINT, [
- 'notnull' => true,
- 'length' => 6,
- ]);
- $table->addColumn('key', Types::STRING, [
- 'notnull' => true,
- 'length' => 64,
- ]);
- $table->addColumn('value', Types::STRING, [
- 'notnull' => true,
- 'length' => 256,
- ]);
- $table->setPrimaryKey(['option_id']);
- $table->addUniqueIndex(['mount_id', 'key'], 'option_mount_key');
- }
- return $schema;
- }
- }
|