1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- declare(strict_types=1);
- namespace OCA\DAV\Migration;
- use OCP\DB\ISchemaWrapper;
- use OCP\DB\Types;
- use OCP\Migration\IOutput;
- use OCP\Migration\SimpleMigrationStep;
- class Version1011Date20190725113607 extends SimpleMigrationStep {
-
- public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
-
- $schema = $schemaClosure();
- $types = ['resource', 'room'];
- foreach ($types as $type) {
- if (!$schema->hasTable($this->getMetadataTableName($type))) {
- $table = $schema->createTable($this->getMetadataTableName($type));
- $table->addColumn('id', Types::BIGINT, [
- 'autoincrement' => true,
- 'notnull' => true,
- 'length' => 11,
- 'unsigned' => true,
- ]);
- $table->addColumn($type . '_id', Types::BIGINT, [
- 'notnull' => true,
- 'length' => 11,
- 'unsigned' => true,
- ]);
- $table->addColumn('key', Types::STRING, [
- 'notnull' => true,
- 'length' => 255,
- ]);
- $table->addColumn('value', Types::STRING, [
- 'notnull' => false,
- 'length' => 4000,
- ]);
- $table->setPrimaryKey(['id']);
- $table->addIndex([$type . '_id', 'key'], $this->getMetadataTableName($type) . '_idk');
- }
- }
- return $schema;
- }
-
- private function getMetadataTableName(string $type):string {
- return 'calendar_' . $type . 's_md';
- }
- }
|