da_agency/lib/Migration/Version000001Date2021052112...

88 lines
2.4 KiB
PHP

<?php
namespace OCA\Agency\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
class Version000001Date20210521125400 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('agencys')) {
$table = $schema->createTable('agencys');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('name', 'string', [
'notnull' => true,
'length' => 200
]);
$table->addColumn('inhaber', 'string', [
'notnull' => false,
'length' => 200
]);
$table->addColumn('street', 'string', [
'notnull' => false,
'length' => 200
]);
$table->addColumn('city', 'string', [
'notnull' => false,
'length' => 200
]);
$table->addColumn('plz', 'string', [
'notnull' => false,
'length' => 5
]);
$table->addColumn('agency_email', 'string', [
'notnull' => false,
'length' => 200
]);
$table->addColumn('phone', 'string', [
'notnull' => false,
'length' => 200
]);
$table->setPrimaryKey(['id']);
}
if (!$schema->hasTable('agency_user')) {
$table = $schema->createTable('agency_user');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->rColumn('agency', 'integer', [
'notnull' => true,
'length' => 64
]);
$table->rColumn('user', 'integer', [
'notnull' => true,
'length' => 64
]);
$table->setPrimaryKey(['id']);
}
return $schema;
}
}