restored the flag table and reference chain modifiactions that somehow got deleted

This commit is contained in:
2026-02-12 20:40:05 -05:00
parent 07a6d352b0
commit d2cb1851d0

View File

@@ -39,5 +39,80 @@ margs="--defaults-extra-file=$mysql_opt_file"
# -------------------------------------
# ---------- version 5.3.0 ------------
# Nothing to do
#
echo "Started database updates for OpenLog version 5.3.0..."
# Import old flag data from old scheme to new flagmap table
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
then
echo "Importing flag data from old scheme to new flagmap table..."
for flagnumber in $(mysql $margs -e "select flagid from flags")
do
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
if [[ -n "$flag_x" ]]
then
for tgtid in $(mysql $margs -e "select id from flag_$flagnumber")
do
target=$(mysql $margs -e "select target from flag_$flagnumber where id=$tgtid")
if [[ $target == "lognotes" ]]
then
mysql $margs -e "insert into flagmap(flagid,lognoteid) values($flagnumber,$tgtid)"
elif [[ $target == "maintforms" ]]
then
mysql $margs -e "insert into flagmap(flagid,maintformid) values($flagnumber,$tgtid)"
elif [[ $target == "notetemplates" ]]
then
mysql $margs -e "insert into flagmap(flagid,notetemplateid) values($flagnumber,$tgtid)"
fi
done
mysql $margs -e "drop table flag_$flagnumber"
fi
done
echo "...done."
fi
# Import reference chain data into new reflinks table
if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]]
then
echo "Importing lognote reference chain data into new reflinks table..."
for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
do
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
oldifs=$IFS
IFS=', '
for target in $refstring
do
target=$(echo "$target" | xargs)
mysql $margs -e "insert into reflinks(noteid,target) values($note,$target)"
done
IFS=$oldifs
done
echo "...done."
echo "Importing template reference chain data into new reflinks table..."
for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
do
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
oldifs=$IFS
IFS=', '
for target in $refstring
do
target=$(echo "$target" | xargs)
mysql $margs -e "insert into reflinks(templateid,target) values($template,$target)"
done
IFS=$oldifs
done
echo "...done."
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1
mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1
fi
# Convert database to utf8mb4/utf8mb4_unicode_ci
echo "Converting database to utf8mb4 encoding..."
mysql $margs -e "ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"
for table in $(mysql $margs -e "show tables")
do
mysql $margs -e "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
done
echo "...done."
# -------------------------------------