Immich: alternate method of migration
This commit is contained in:
parent
0163e04f1c
commit
58ad137936
29
ct/immich.sh
29
ct/immich.sh
@ -184,15 +184,38 @@ function update_script() {
|
|||||||
msg_ok "Stopped ${APP}"
|
msg_ok "Stopped ${APP}"
|
||||||
if [[ "$(cat /opt/${APP}_version.txt)" < "1.133.0" ]]; then
|
if [[ "$(cat /opt/${APP}_version.txt)" < "1.133.0" ]]; then
|
||||||
msg_info "Upgrading to the VectorChord PostgreSQL extension"
|
msg_info "Upgrading to the VectorChord PostgreSQL extension"
|
||||||
|
NUMBER="$(
|
||||||
|
sed -n '2p' <(
|
||||||
|
sudo -u postgres psql -A -d immich <<EOF
|
||||||
|
SELECT atttypmod as dimsize
|
||||||
|
FROM pg_attribute f
|
||||||
|
JOIN pg_class c ON c.oid = f.attrelid
|
||||||
|
WHERE c.relkind = 'r'::char
|
||||||
|
AND f.attnum > 0
|
||||||
|
AND c.relname = 'smart_search'::text
|
||||||
|
AND f.attname = 'embedding'::text;
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
$STD sudo -u postgres psql -d immich <<EOF
|
||||||
|
DROP INDEX IF EXISTS clip_index;
|
||||||
|
DROP INDEX IF EXISTS face_index;
|
||||||
|
ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE real[];
|
||||||
|
ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE real[];
|
||||||
|
EOF
|
||||||
$STD apt-get update
|
$STD apt-get update
|
||||||
$STD apt-get install postgresql-16-pgvector -y
|
$STD apt-get install postgresql-16-pgvector -y
|
||||||
curl -fsSL https://github.com/tensorchord/VectorChord/releases/download/0.3.0/postgresql-16-vchord_0.3.0-1_amd64.deb -o vchord.deb
|
curl -fsSL https://github.com/tensorchord/VectorChord/releases/download/0.3.0/postgresql-16-vchord_0.3.0-1_amd64.deb -o vchord.deb
|
||||||
$STD dpkg -i vchord.deb
|
$STD dpkg -i vchord.deb
|
||||||
rm vchord.deb
|
rm vchord.deb
|
||||||
sed -i -e "s/'vectors.so'/'vchord.so, vectors.so'/" \
|
sed -i "s|vectors.so|vchord.so|" /etc/postgresql/16/main/postgresql.conf
|
||||||
-e "/^search_path/s/, vectors//" /etc/postgresql/16/main/postgresql.conf
|
|
||||||
systemctl restart postgresql.service
|
systemctl restart postgresql.service
|
||||||
msg_ok "Upgrade in progress. When Immich restarts, watch the logs for 're-indexing' to complete"
|
$STD sudo -u postgres psql -d immich <<EOF
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vchord CASCADE;
|
||||||
|
ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE vector($NUMBER);
|
||||||
|
ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE vector(512);
|
||||||
|
EOF
|
||||||
|
msg_ok "Database upgrade complete"
|
||||||
fi
|
fi
|
||||||
INSTALL_DIR="/opt/${APP}"
|
INSTALL_DIR="/opt/${APP}"
|
||||||
UPLOAD_DIR="${INSTALL_DIR}/upload"
|
UPLOAD_DIR="${INSTALL_DIR}/upload"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user