1
0
Fork 0

add subscriptions table creation migration

This commit is contained in:
Jonathan Treffler 2024-06-12 01:48:59 +02:00
parent 8dc989f897
commit 32aa0aa386

View file

@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace OCA\DavPush\Migration;
use Closure;
use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
class Version001Date20240515221000 extends SimpleMigrationStep {
public const SUBSCRIPTIONS_TABLE = "dav_push_subscriptions";
/**
* @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(self::SUBSCRIPTIONS_TABLE)) {
$table = $schema->createTable(self::SUBSCRIPTIONS_TABLE);
$table->addColumn('id', Types::INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('user_id', Types::STRING, [
'notnull' => true,
'length' => 200,
]);
$table->addColumn('collection_name', Types::STRING, [
'notnull' => true,
'length' => 100,
]);
$table->addColumn('data', Types::TEXT, [
'notnull' => true,
]);
$table->addColumn('creation_timestamp', Types::BIGINT, [
'notnull' => true,
]);
$table->addColumn('expiration_timestamp', Types::BIGINT, [
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
}
return $schema;
}
}