83 lines
2.2 KiB
PHP
83 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Radio\Migration;
|
|
|
|
use Closure;
|
|
use OCP\DB\ISchemaWrapper;
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
use OCP\Migration\IOutput;
|
|
|
|
class Version000000Date20181013124731 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('favorites')) {
|
|
$table = $schema->createTable('favorites');
|
|
$table->addColumn('id', 'integer', [
|
|
'autoincrement' => true,
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('stationuuid', 'string', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('user_id', 'string', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('name', 'text', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('favicon', 'text');
|
|
$table->addColumn('urlresolved', 'text');
|
|
$table->addColumn('bitrate', 'text');
|
|
$table->addColumn('country', 'text');
|
|
$table->addColumn('language', 'text');
|
|
$table->addColumn('homepage', 'text');
|
|
$table->addColumn('codec', 'text');
|
|
$table->addColumn('tags', 'text');
|
|
|
|
$table->setPrimaryKey(['id']);
|
|
$table->addIndex(['user_id'], 'favorites_user_id_index');
|
|
}
|
|
|
|
if (!$schema->hasTable('recent')) {
|
|
$table = $schema->createTable('recent');
|
|
$table->addColumn('id', 'integer', [
|
|
'autoincrement' => true,
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('stationuuid', 'string', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('user_id', 'string', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('name', 'text', [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('favicon', 'text');
|
|
$table->addColumn('urlresolved', 'text');
|
|
$table->addColumn('bitrate', 'text');
|
|
$table->addColumn('country', 'text');
|
|
$table->addColumn('language', 'text');
|
|
$table->addColumn('homepage', 'text');
|
|
$table->addColumn('codec', 'text');
|
|
$table->addColumn('tags', 'text');
|
|
|
|
$table->setPrimaryKey(['id']);
|
|
$table->addIndex(['user_id'], 'recent_user_id_index');
|
|
}
|
|
|
|
return $schema;
|
|
}
|
|
}
|