summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-11-27 15:22:33 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-11-27 15:22:33 +0000
commit73ffd898650f6cb75d323cc438845a3aead1b110 (patch)
treee92d68f9802fd2ae1e7479d0e02935ac350bb1bf /contrib
parentaacaa350f7da7c154264897da26d15ff38df46bb (diff)
downloadxxv-73ffd898650f6cb75d323cc438845a3aead1b110.tar.gz
xxv-73ffd898650f6cb75d323cc438845a3aead1b110.tar.bz2
* Database: Change method of version control, use comment from table, instead use table 'VERSION'
* RECORDS: Use MD5 for mapping preview images * RECORDS: Don't use 2nd try to generate preview images * Handle field names from table now with special character, remove prior workaround * TIMER: Search lookup also for description * buildsearch: redesign avoid SQL-Injection * AUTOTIMER: Speed up background scan, compare now only changed und added epg-events
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/update-xxv52
-rw-r--r--contrib/upgrade-xxv-db.sql11
2 files changed, 40 insertions, 23 deletions
diff --git a/contrib/update-xxv b/contrib/update-xxv
index b9151e5..eea478c 100755
--- a/contrib/update-xxv
+++ b/contrib/update-xxv
@@ -18,7 +18,7 @@
# Increment the version number each time the database changes!
#
-actualVersion=25
+actualVersion=26
# Specify tables to export before and import after update
#
@@ -140,14 +140,17 @@ importDb()
showInfo 'Restoring Data'
for table in $tables ; do
savFile="$exportDir/$table.sav"
- if ! eval mysql $mysqlParams -f -B $database -e \
- "\"load data infile '$savFile' into table $table;\"" ; then
- showError "Can't load table '$table'"
- exit 1
+ if [ -e "$savfile" ]; then
+ if ! eval mysql $mysqlParams -f -B $database -e \
+ "\"load data infile '$savFile' into table $table;\"" ; then
+ showError "Can't load table '$table'"
+ exit 1
+ fi
fi
done
}
+
updateDb()
{
showInfo 'Updating Database'
@@ -164,19 +167,42 @@ getActualVersion()
getVersion()
{
+ minver=10000000;
+ maxver=0;
showInfo 'Retrieving current version'
- version=`eval mysql $mysqlParams -f -B -s $database -e \
- "\"select Version from VERSION;\"" 2>/dev/null`
+ for table in $tables ; do
+ tableversion=`eval mysql $mysqlParams -f -B -s $database -e \
+ "\"SHOW TABLE STATUS LIKE '$table';\"" 2>/dev/null | cut -f 18`
+ if [ -n "$tableversion" -a "$tableversion" -eq "$tableversion" ] ; then
+ if [ "$tableversion" -lt "$minver" ] ; then
+ minver="$tableversion"
+ fi
+ if [ "$tableversion" -gt "$maxver" ] ; then
+ maxver="$tableversion"
+ fi
+ else
+ minver="0"
+ fi
+ done
+
+ if [ "$minver" -ne "$maxver" ] ; then
+ showInfo "Mixed versions of tables: '$minver' until '$maxver'";
+ fi
+ if [ "$minver" -ne 10000000 ] ; then
+ version=$minver
+ fi
}
updateVersion()
{
showInfo 'Updateing Version'
- if ! eval mysql $mysqlParams -f -B $database -e \
- "\"insert into VERSION (Version) VALUES($actualVersion);\"" ; then
- showError 'Could not set new version number!!!'
- exit 1
- fi
+ for table in $tables ; do
+ if ! eval mysql $mysqlParams -f -B $database -e \
+ "\"ALTER TABLE $table COMMENT '$actualVersion';\"" ; then
+ showError "Can't alter table '$table'"
+ exit 1
+ fi
+ done
}
#
@@ -261,7 +287,7 @@ if [ $actualVersion -lt $version ] ; then
fi
# backup
-if [ ! -z $backupTarget ] ; then
+if [ -n $backupTarget ] ; then
showInfo 'Performing backup...'
mysqldump $mysqlParams $database | gzip >"$backupTarget.gz" 2>/dev/null
if [ $? -ne 0 ] ; then
diff --git a/contrib/upgrade-xxv-db.sql b/contrib/upgrade-xxv-db.sql
index af58b6a..bd39e29 100644
--- a/contrib/upgrade-xxv-db.sql
+++ b/contrib/upgrade-xxv-db.sql
@@ -143,15 +143,6 @@ CREATE TABLE `USER` (
`MaxPriority` tinyint(2) default '0',
PRIMARY KEY (`Id`)
);
-
---
--- Table structure for table `VERSION`
---
-
-DROP TABLE IF EXISTS `VERSION`;
-CREATE TABLE `VERSION` (
- `Version` tinyint(4) NOT NULL default '0'
-);
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -159,4 +150,4 @@ CREATE TABLE `VERSION` (
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2007-11-24 11:40:15
+-- Dump completed on 2007-11-24 14:27:24