mirror of
https://github.com/YunoHost-Apps/shiori_ynh.git
synced 2024-09-03 20:26:17 +02:00
migrate fts4 to fts5
This commit is contained in:
parent
61c1ea2ab7
commit
52aed4da61
1 changed files with 33 additions and 0 deletions
|
@ -40,6 +40,39 @@ chmod -R o-rwx "$install_dir"
|
|||
chown -R $app:www-data "$install_dir"
|
||||
chmod +x "$install_dir/shiori"
|
||||
|
||||
#=================================================
|
||||
# MIGRATE AND UPGRADE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
if ynh_compare_current_pacakge_version --comparison lt --version 1.50~ynh9
|
||||
then
|
||||
ynh_script_progression --message="Migrating sqlite from version < 1.50~ynh9..." --weight=1
|
||||
FTS4_EXISTS=$(sqlite3 "$data_dir/shiori.db" "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'bookmark_content' AND sql LIKE '%USING fts4%';")
|
||||
if [ -z "$FTS4_EXISTS" ]
|
||||
then
|
||||
echo "No FTS4 table found or already migrated"
|
||||
else
|
||||
sqlite3 "$data_dir/shiori.db" "BEGIN TRANSACTION; CREATE VIRTUAL TABLE bookmark_content_fts5 USING fts5(title, content, html, docid); INSERT INTO bookmark_content_fts5 (title, content, html, docid) SELECT title, content, html, docid FROM bookmark_content; DROP TABLE bookmark_content; ALTER TABLE bookmark_content_fts5 RENAME TO bookmark_content; COMMIT;"
|
||||
fi
|
||||
|
||||
SCHEMA_MIGRATIONS_EXISTS=$(sqlite3 "$data_dir/shiori.db" "SELECT name FROM sqlite_master WHERE type='table' AND name='schema_migrations';")
|
||||
if [ -z "$SCHEMA_MIGRATIONS_EXISTS" ]; then
|
||||
echo "No schema_migrations table found, skipping"
|
||||
else
|
||||
DIRTY=$(sqlite3 "$data_dir/shiori.db" "SELECT dirty FROM schema_migrations WHERE dirty = 1;")
|
||||
if [ -z "$DIRTY" ]; then
|
||||
echo "No dirty migrations found, skipping"
|
||||
else
|
||||
VERSION=$(sqlite3 "$data_dir/shiori.db" "SELECT version FROM schema_migrations WHERE dirty = 1;")
|
||||
NEW_VERSION=$((VERSION - 1))
|
||||
sqlite3 "$data_dir/shiori.db" "UPDATE schema_migrations SET version = $NEW_VERSION, dirty = 0 WHERE dirty = 1;"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue