Switch database setup to use migrations.
This commit is contained in:
parent
4e6009c530
commit
660fbeae76
2 changed files with 41 additions and 52 deletions
|
|
@ -1,52 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<database>
|
|
||||||
<name>*dbname*</name>
|
|
||||||
<create>true</create>
|
|
||||||
<overwrite>false</overwrite>
|
|
||||||
<charset>utf8</charset>
|
|
||||||
<table>
|
|
||||||
<name>*dbprefix*pdfdraw_items</name>
|
|
||||||
<declaration>
|
|
||||||
<field>
|
|
||||||
<name>file_id</name>
|
|
||||||
<type>text</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>page</name>
|
|
||||||
<type>integer</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>name</name>
|
|
||||||
<type>text</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>data</name>
|
|
||||||
<type>clob</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<index>
|
|
||||||
<name>fileid_index</name>
|
|
||||||
<field>
|
|
||||||
<name>file_id</name>
|
|
||||||
<sorting>ascending</sorting>
|
|
||||||
</field>
|
|
||||||
</index>
|
|
||||||
<index>
|
|
||||||
<name>fileid_name_index</name>
|
|
||||||
<primary>true</primary>
|
|
||||||
<unique>true</unique>
|
|
||||||
<field>
|
|
||||||
<name>file_id</name>
|
|
||||||
<sorting>ascending</sorting>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>name</name>
|
|
||||||
<sorting>ascending</sorting>
|
|
||||||
</field>
|
|
||||||
</index>
|
|
||||||
</declaration>
|
|
||||||
</table>
|
|
||||||
</database>
|
|
||||||
41
lib/Migration/Version1000Date20211122150107.php
Normal file
41
lib/Migration/Version1000Date20211122150107.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
namespace OCA\Pdfdraw\Migration;
|
||||||
|
|
||||||
|
use OCP\DB\ISchemaWrapper;
|
||||||
|
use OCP\Migration\SimpleMigrationStep;
|
||||||
|
use OCP\Migration\IOutput;
|
||||||
|
|
||||||
|
class Version1000Date20211122150107 extends SimpleMigrationStep {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param IOutput $output
|
||||||
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||||
|
* @param array $options
|
||||||
|
* @return null|ISchemaWrapper
|
||||||
|
* @since 13.0.0
|
||||||
|
*/
|
||||||
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||||
|
/** @var ISchemaWrapper $schema */
|
||||||
|
$schema = $schemaClosure();
|
||||||
|
|
||||||
|
if (!$schema->hasTable('pdfdraw_items')) {
|
||||||
|
$table = $schema->createTable('pdfdraw_items');
|
||||||
|
$table->addColumn('file_id', 'string', [
|
||||||
|
'notnull' => true,
|
||||||
|
]);
|
||||||
|
$table->addColumn('page', 'integer', [
|
||||||
|
'notnull' => true,
|
||||||
|
]);
|
||||||
|
$table->addColumn('name', 'string', [
|
||||||
|
'notnull' => true,
|
||||||
|
]);
|
||||||
|
$table->addColumn('data', 'text', [
|
||||||
|
'notnull' => true,
|
||||||
|
]);
|
||||||
|
$table->setPrimaryKey(['file_id', 'name']);
|
||||||
|
$table->addIndex(['file_id'], 'fileid_index');
|
||||||
|
}
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue