fat32compat & ascii as separate columns in DB
This commit is contained in:
parent
142c5438e6
commit
1b801cbe12
@ -1,18 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
currentdbversion=1
|
currentdbversion=2
|
||||||
checkDatabaseVersion() {
|
checkDatabaseVersion() {
|
||||||
local dbversion
|
local dbversion
|
||||||
if dbversion=$(Select atom version <<<"1 = 1")
|
if dbversion=$(Select atom version <<<"\"1\" = 1")
|
||||||
then
|
then
|
||||||
if (( dbversion == currentdbversion ))
|
if (( dbversion == currentdbversion ))
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
elif (( dbversion < currentversion ))
|
elif (( dbversion < currentdbversion ))
|
||||||
then
|
then
|
||||||
until (( dbversion == currentversion ))
|
until (( dbversion == currentdbversion ))
|
||||||
do
|
do
|
||||||
upgradedatabase_${dbversion}_$((dbversion+1))
|
upgradedatabase_${dbversion}_$((dbversion+1))
|
||||||
dbversion=$(Select atom version <<<"1 = 1")
|
dbversion=$(Select atom version <<<"\"1\" = 1")
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Database schema version $dbversion is higher than
|
echo "Database schema version $dbversion is higher than
|
||||||
@ -23,4 +23,5 @@ checkDatabaseVersion() {
|
|||||||
else
|
else
|
||||||
Insert atom 1 <<<"version $currentdbversion"
|
Insert atom 1 <<<"version $currentdbversion"
|
||||||
fi
|
fi
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
|||||||
37
lib/database/upgradedatabase_1_2
Normal file
37
lib/database/upgradedatabase_1_2
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
upgradedatabase_1_2() {
|
||||||
|
echo "Upgrading database to version 2... (backup is $database.bak_v1)"
|
||||||
|
cp "$database" "$database.bak_v1"
|
||||||
|
echo 'ALTER TABLE destination_files ADD COLUMN fat32compat INTEGER;' >&3
|
||||||
|
echo 'ALTER TABLE destination_files ADD COLUMN ascii INTEGER;' >&3
|
||||||
|
echo '
|
||||||
|
SELECT id,
|
||||||
|
rename_pattern
|
||||||
|
FROM destination_files;
|
||||||
|
|
||||||
|
SELECT "AtOM::NoMoreData";' >&3
|
||||||
|
|
||||||
|
read -u4 data
|
||||||
|
while [[ $data != AtOM::NoMoreData ]]
|
||||||
|
do
|
||||||
|
datas+=( "$data" )
|
||||||
|
read -u4 data
|
||||||
|
done
|
||||||
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
|
for data in "${datas[@]}"
|
||||||
|
do
|
||||||
|
id="${data%%::AtOM:SQL:Sep::*}"
|
||||||
|
rename_pattern="${data#*::AtOM:SQL:Sep::}"
|
||||||
|
IFS=':'
|
||||||
|
read pattern fat32 <<<"$rename_pattern"
|
||||||
|
IFS="$oldIFS"
|
||||||
|
Update destination_files \
|
||||||
|
rename_pattern "$pattern" \
|
||||||
|
fat32compat "$fat32" \
|
||||||
|
ascii 0 \
|
||||||
|
<<<"id = $id"
|
||||||
|
done
|
||||||
|
echo 'COMMIT;' >&3
|
||||||
|
Update atom version 2 <<<"1 = 1"
|
||||||
|
}
|
||||||
14
lib/tools/ascii
Normal file
14
lib/tools/ascii
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ascii() {
|
||||||
|
coproc toascii {
|
||||||
|
perl -e '
|
||||||
|
use utf8;
|
||||||
|
use Text::Unidecode;
|
||||||
|
use open qw(:std :utf8);
|
||||||
|
$| = 1;
|
||||||
|
while (<>) {
|
||||||
|
print(unidecode($_));
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,6 +22,8 @@ CREATE TABLE IF NOT EXISTS destination_files (
|
|||||||
filename TEXT,
|
filename TEXT,
|
||||||
old_filename TEXT,
|
old_filename TEXT,
|
||||||
rename_pattern TEXT,
|
rename_pattern TEXT,
|
||||||
|
fat32compat INTEGER,
|
||||||
|
ascii INTEGER,
|
||||||
last_change FLOAT NOT NULL DEFAULT 0,
|
last_change FLOAT NOT NULL DEFAULT 0,
|
||||||
source_file_id INTEGER,
|
source_file_id INTEGER,
|
||||||
destination_id INTEGER,
|
destination_id INTEGER,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user