我在 Archlinux 上运行 Digikam,我的照片数据库存储在 MariaDB 中。这工作得很好,直到最近升级。当我尝试打开 Digikam 时,它返回:
无法将数据库架构从版本 12 更新到版本 13。请阅读控制台上打印的错误消息,并在 bugs.kde.org 上将此错误报告为错误。
从控制台打开它时,会显示以下消息:
digikam.coredb:核心数据库:无法处理架构初始化 QThreadStorage:线程 0x7f77f1091560 在 QThreadStorage 13 销毁后退出
答案1
有一个 dbconfig.xml 文件,在我的例子中位于:
/usr/share/digikam/database/dbconfig.xml
该文件包含需要运行的 SQL 命令。在这种情况下,我隔离了以下代码:
DROP PROCEDURE IF EXISTS create_index_if_not_exists;
CREATE PROCEDURE create_index_if_not_exists(table_name_vc varchar(50), index_name_vc varchar(50), field_list_vc varchar(1024))
BEGIN
set @Index_cnt = (
SELECT COUNT(1) cnt
FROM INFORMATION_SCHEMA.STATISTICS
WHERE CONVERT(DATABASE() USING latin1) = CONVERT(TABLE_SCHEMA USING latin1)
AND CONVERT(table_name USING latin1) = CONVERT(table_name_vc USING latin1)
AND CONVERT(index_name USING latin1) = CONVERT(index_name_vc USING latin1)
);
IF IFNULL(@Index_cnt, 0) = 0 THEN
set @index_sql = CONCAT(
CONVERT( 'ALTER TABLE ' USING latin1),
CONVERT( table_name_vc USING latin1),
CONVERT( ' ADD INDEX ' USING latin1),
CONVERT( index_name_vc USING latin1),
CONVERT( '(' USING latin1),
CONVERT( field_list_vc USING latin1),
CONVERT( ');' USING latin1)
);
PREPARE stmt FROM @index_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END;
CALL create_index_if_not_exists('TagsTree','tagstree_id_index','id');
CALL create_index_if_not_exists('TagsTree','tagstree_pid_index','pid');
ALTER TABLE UniqueHashes CHANGE uniqueHash uniqueHash VARCHAR(128);
CREATE TABLE IF NOT EXISTS CustomIdentifiers
(identifier LONGTEXT CHARACTER SET utf8,
thumbId INTEGER,
UNIQUE(identifier(333)));
CALL create_index_if_not_exists('CustomIdentifiers','id_customIdentifiers','thumbId');
ALTER TABLE Settings RENAME ThumbSettings;
ALTER TABLE ThumbSettings
MODIFY COLUMN keyword VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci,
MODIFY COLUMN value LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE ThumbSettings ENGINE InnoDB;
ALTER TABLE Thumbnails ENGINE InnoDB;
ALTER TABLE UniqueHashes ENGINE InnoDB;
ALTER TABLE FilePaths MODIFY COLUMN path VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE FilePaths ENGINE InnoDB;
ALTER TABLE CustomIdentifiers MODIFY COLUMN identifier VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE CustomIdentifiers ENGINE InnoDB;
ALTER TABLE UniqueHashes
ADD CONSTRAINT UniqueHashes_Thumbnails FOREIGN KEY (thumbId) REFERENCES Thumbnails (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE FilePaths
ADD CONSTRAINT FilePaths_Thumbnails FOREIGN KEY (thumbId) REFERENCES Thumbnails (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE CustomIdentifiers
ADD CONSTRAINT CustomIdentifiers_Thumbnails FOREIGN KEY (thumbId) REFERENCES Thumbnails (id) ON DELETE CASCADE ON UPDATE CASCADE;
OPTIMIZE TABLE Albums, Images, ImageInformation, ImageMetadata, VideoMetadata, ImagePositions, ImageComments, ImageCopyright, ImageProperties, ImageHistory, ImageRelations, Tags, ImageTags, ImageTagProperties;
OPTIMIZE TABLE Thumbnails, UniqueHashes, FilePaths, CustomIdentifiers;
OPTIMIZE TABLE Identities, IdentityAttributes;
OPTIMIZE TABLE ImageSimilarity, ImageHaarMatrix, SimilaritySettings;
CHECK TABLE Albums, Images, ImageInformation, ImageMetadata, VideoMetadata, ImagePositions, ImageComments, ImageCopyright, ImageProperties, ImageHistory, ImageRelations, Tags, ImageTags, ImageTagProperties;
CHECK TABLE Thumbnails, UniqueHashes, FilePaths, CustomIdentifiers;
CHECK TABLE Identities, IdentityAttributes;
CHECK TABLE ImageSimilarity, ImageHaarMatrix, SimilaritySettings;
我直接在保存我的照片的数据库上运行它。有一些错误,但运行后这个 digikam 开始正常,一切看起来都井然有序。
答案2
不幸的是,我无法评论@user74934的答案,但是我尝试运行他的代码并得到了ERROR 1728 (HY000): Cannot load from mysql.proc. The table is probably corrupted
mariadb 的错误。
如果有人遇到这个问题,我可以从 StackOverflow 中得到灵感来解决它回答。我运行了命令:mariadb-upgrade --socket=mysql.socket digikam
为了修复我的实例。