Fix database index name length issue
This commit is contained in:
parent
ff68682b75
commit
048b77192e
@ -16,7 +16,7 @@ use OCP\IDBConnection;
|
|||||||
class PreferenceMapper extends ReaderMapper {
|
class PreferenceMapper extends ReaderMapper {
|
||||||
|
|
||||||
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
public function __construct(IDBConnection $db, $UserId, Time $time) {
|
||||||
parent::__construct($db, 'reader_preferences', Preference::class, $time);
|
parent::__construct($db, 'reader_prefs', Preference::class, $time);
|
||||||
$this->userId = $UserId;
|
$this->userId = $UserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,14 +30,14 @@ class PreferenceMapper extends ReaderMapper {
|
|||||||
*/
|
*/
|
||||||
public function get($scope, $fileId, $name=null) {
|
public function get($scope, $fileId, $name=null) {
|
||||||
if(!empty($name)) {
|
if(!empty($name)) {
|
||||||
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE `scope`=? AND `file_id`=? AND `user_id`=? AND `name`=?";
|
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=? AND `name`=?";
|
||||||
$args = array(
|
$args = array(
|
||||||
$scope,
|
$scope,
|
||||||
$fileId,
|
$fileId,
|
||||||
$this->userId,
|
$this->userId,
|
||||||
$name);
|
$name);
|
||||||
} else {
|
} else {
|
||||||
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE `scope`=? AND `file_id`=? AND `user_id`=?";
|
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=?";
|
||||||
$args = array(
|
$args = array(
|
||||||
$scope,
|
$scope,
|
||||||
$fileId,
|
$fileId,
|
||||||
@ -83,7 +83,7 @@ class PreferenceMapper extends ReaderMapper {
|
|||||||
|
|
||||||
/* currently not used*/
|
/* currently not used*/
|
||||||
public function deleteForFileId($fileId) {
|
public function deleteForFileId($fileId) {
|
||||||
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE file_id=?";
|
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE file_id=?";
|
||||||
$args = [ $fileId ];
|
$args = [ $fileId ];
|
||||||
array_map(
|
array_map(
|
||||||
function($entity) {
|
function($entity) {
|
||||||
@ -94,7 +94,7 @@ class PreferenceMapper extends ReaderMapper {
|
|||||||
|
|
||||||
/* currently not used*/
|
/* currently not used*/
|
||||||
public function deleteForUserId($userId) {
|
public function deleteForUserId($userId) {
|
||||||
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE user_id=?";
|
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE user_id=?";
|
||||||
$args = [ $userId ];
|
$args = [ $userId ];
|
||||||
array_map(
|
array_map(
|
||||||
function($entity) {
|
function($entity) {
|
||||||
|
@ -50,7 +50,7 @@ class Hooks {
|
|||||||
$queryBuilder->execute();
|
$queryBuilder->execute();
|
||||||
|
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$queryBuilder = $connection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_preferences')->where('file_id = :file_id')->setParameter(':file_id', $fileId);
|
$queryBuilder->delete('reader_prefs')->where('file_id = :file_id')->setParameter(':file_id', $fileId);
|
||||||
$queryBuilder->execute();
|
$queryBuilder->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class Hooks {
|
|||||||
$queryBuilder->execute();
|
$queryBuilder->execute();
|
||||||
|
|
||||||
$queryBuilder = $connection->getQueryBuilder();
|
$queryBuilder = $connection->getQueryBuilder();
|
||||||
$queryBuilder->delete('reader_preferences')->where('user_id = :user_id')->setParameter(':user_id', $userId);
|
$queryBuilder->delete('reader_prefs')->where('user_id = :user_id')->setParameter(':user_id', $userId);
|
||||||
$queryBuilder->execute();
|
$queryBuilder->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ class Version010402Date20200508180941 extends SimpleMigrationStep {
|
|||||||
$table->addIndex(['name'], 'reader_bookmarks_name_index');
|
$table->addIndex(['name'], 'reader_bookmarks_name_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$schema->hasTable('reader_preferences')) {
|
if (!$schema->hasTable('reader_prefs')) {
|
||||||
$table = $schema->createTable('reader_preferences');
|
$table = $schema->createTable('reader_prefs');
|
||||||
$table->addColumn('id', 'bigint', [
|
$table->addColumn('id', 'bigint', [
|
||||||
'autoincrement' => true,
|
'autoincrement' => true,
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
@ -126,9 +126,9 @@ class Version010402Date20200508180941 extends SimpleMigrationStep {
|
|||||||
'unsigned' => true,
|
'unsigned' => true,
|
||||||
]);
|
]);
|
||||||
$table->setPrimaryKey(['id']);
|
$table->setPrimaryKey(['id']);
|
||||||
$table->addIndex(['file_id'], 'reader_preferences_file_id_index');
|
$table->addIndex(['file_id'], 'reader_prefs_file_id_index');
|
||||||
$table->addIndex(['user_id'], 'reader_preferences_user_id_index');
|
$table->addIndex(['user_id'], 'reader_prefs_user_id_index');
|
||||||
$table->addIndex(['scope'], 'reader_preferences_scope_index');
|
$table->addIndex(['scope'], 'reader_prefs_scope_index');
|
||||||
}
|
}
|
||||||
return $schema;
|
return $schema;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user