memories/lib/Migration/Version000000Date2022081216...

57 lines
1.8 KiB
PHP
Raw Normal View History

2022-08-13 01:58:37 +00:00
<?php
2022-08-16 01:19:43 +00:00
namespace OCA\Polaroid\Migration;
2022-08-13 01:58:37 +00:00
use Closure;
use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
class Version000000Date20220812163631 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();
2022-08-16 01:19:43 +00:00
if (!$schema->hasTable('polaroid')) {
$table = $schema->createTable('polaroid');
2022-08-13 01:58:37 +00:00
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 200,
]);
2022-08-16 04:31:09 +00:00
$table->addColumn('date_taken', Types::DATETIME, [
2022-08-13 01:58:37 +00:00
'notnull' => false,
]);
$table->addColumn('file_id', Types::BIGINT, [
'notnull' => true,
'length' => 20,
]);
2022-08-14 23:19:13 +00:00
$table->addColumn('day_id', Types::INTEGER, [
'notnull' => true,
]);
2022-08-16 00:46:36 +00:00
$table->addColumn('is_video', Types::BOOLEAN, [
'notnull' => false,
'default' => false
]);
2022-08-13 01:58:37 +00:00
$table->setPrimaryKey(['id']);
2022-08-16 01:19:43 +00:00
$table->addIndex(['user_id'], 'polaroid_user_id_index');
$table->addIndex(['day_id'], 'polaroid_day_id_index');
2022-08-16 02:47:49 +00:00
$table->addIndex(['user_id', 'day_id'], 'polaroid_ud_index');
2022-08-16 01:19:43 +00:00
$table->addUniqueIndex(['user_id', 'file_id'], 'polaroid_day_uf_ui');
2022-08-13 01:58:37 +00:00
}
2022-08-14 23:19:13 +00:00
2022-08-13 01:58:37 +00:00
return $schema;
}
}