2020-05-08 18:15:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\Epubreader\Migration;
|
|
|
|
|
|
|
|
use OCP\DB\ISchemaWrapper;
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
|
|
|
|
|
|
/**
|
2023-08-02 20:04:03 +00:00
|
|
|
* Auto-generated migration step.
|
2020-05-08 18:15:18 +00:00
|
|
|
*/
|
2023-08-02 20:04:03 +00:00
|
|
|
class Version010404Date20201030180941 extends SimpleMigrationStep
|
|
|
|
{
|
2020-05-08 18:15:18 +00:00
|
|
|
/**
|
2023-08-02 20:04:03 +00:00
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
2020-05-08 18:15:18 +00:00
|
|
|
*/
|
2023-08-02 20:04:03 +00:00
|
|
|
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
|
|
|
|
{
|
2020-05-08 18:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-08-02 20:04:03 +00:00
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
2020-05-08 18:15:18 +00:00
|
|
|
*/
|
2023-08-02 20:04:03 +00:00
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper
|
|
|
|
{
|
2020-05-08 18:15:18 +00:00
|
|
|
/** @var ISchemaWrapper $schema */
|
|
|
|
$schema = $schemaClosure();
|
|
|
|
|
|
|
|
if (!$schema->hasTable('reader_bookmarks')) {
|
|
|
|
$table = $schema->createTable('reader_bookmarks');
|
|
|
|
$table->addColumn('id', 'bigint', [
|
|
|
|
'autoincrement' => true,
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 8,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
// user ID, maps bookmark to NC/OC user
|
|
|
|
$table->addColumn('user_id', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 64,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
// file ID, maps to NC/OC file ID
|
|
|
|
$table->addColumn('file_id', 'bigint', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 11,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
// type (bookmark, annotation, etc)
|
|
|
|
$table->addColumn('type', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 32,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('name', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 512,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('value', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 512,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('content', 'string', [
|
|
|
|
'notnull' => false,
|
2022-05-27 22:28:13 +00:00
|
|
|
'length' => 4000,
|
2020-05-08 18:15:18 +00:00
|
|
|
]);
|
|
|
|
$table->addColumn('last_modified', 'bigint', [
|
|
|
|
'notnull' => false,
|
|
|
|
'length' => 8,
|
|
|
|
'default' => 0,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
$table->setPrimaryKey(['id']);
|
|
|
|
$table->addIndex(['file_id'], 'reader_bookmarks_file_id_index');
|
|
|
|
$table->addIndex(['user_id'], 'reader_bookmarks_user_id_index');
|
|
|
|
$table->addIndex(['name'], 'reader_bookmarks_name_index');
|
|
|
|
}
|
|
|
|
|
2020-10-31 20:05:16 +00:00
|
|
|
if (!$schema->hasTable('reader_prefs')) {
|
|
|
|
$table = $schema->createTable('reader_prefs');
|
2020-05-08 18:15:18 +00:00
|
|
|
$table->addColumn('id', 'bigint', [
|
|
|
|
'autoincrement' => true,
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 8,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
// user ID, maps preference to NC/OC user
|
|
|
|
$table->addColumn('user_id', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 64,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
// file ID, maps to NC/OC file ID
|
|
|
|
$table->addColumn('file_id', 'bigint', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 11,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
$table->addColumn('scope', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 32,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('name', 'string', [
|
|
|
|
'notnull' => true,
|
|
|
|
'length' => 128,
|
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('value', 'string', [
|
|
|
|
'notnull' => true,
|
2022-05-27 22:28:13 +00:00
|
|
|
'length' => 4000,
|
2020-05-08 18:15:18 +00:00
|
|
|
'default' => '',
|
|
|
|
]);
|
|
|
|
$table->addColumn('last_modified', 'bigint', [
|
|
|
|
'notnull' => false,
|
|
|
|
'length' => 8,
|
|
|
|
'default' => 0,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
$table->setPrimaryKey(['id']);
|
2020-10-31 20:05:16 +00:00
|
|
|
$table->addIndex(['file_id'], 'reader_prefs_file_id_index');
|
|
|
|
$table->addIndex(['user_id'], 'reader_prefs_user_id_index');
|
|
|
|
$table->addIndex(['scope'], 'reader_prefs_scope_index');
|
2020-05-08 18:15:18 +00:00
|
|
|
}
|
2023-08-02 20:04:03 +00:00
|
|
|
|
2020-05-08 18:15:18 +00:00
|
|
|
return $schema;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-08-02 20:04:03 +00:00
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
2020-05-08 18:15:18 +00:00
|
|
|
*/
|
2023-08-02 20:04:03 +00:00
|
|
|
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
|
|
|
|
{
|
2020-05-08 18:15:18 +00:00
|
|
|
}
|
|
|
|
}
|