Files
moneyplanner/lib/Migration/Version000000Date20190320115800.php
2026-07-05 21:52:31 +02:00

46 lines
1.3 KiB
PHP

<?php
namespace OCA\MoneyPlanner\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
class Version000000Date20190320115800 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('moneyplanner_accounts')) {
$table = $schema->createTable('moneyplanner_accounts');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 64
]);
$table->addColumn('name', 'string', [
'notnull' => true,
'length' => 255
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'moneyplanner_accounts_user_id_index');
$table->addUniqueIndex(['user_id', 'name'], 'moneyplanner_accounts_user_name_index');
}
return $schema;
}
}
?>