Ignore:
Timestamp:
Jul 19, 2017, 12:05:17 PM (3 years ago)
Author:
mabarracus
Message:

Complete code rewrite
New database model
Improved performance & optimization
Extended information about clients
Fixed older bugs
New testing framework
Fix postinst exit code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lliurex-analytics-server/trunk/fuentes/debian/postinst

    r5136 r5560  
    149149
    150150# UPDATE DB FROM OLDER VERSIONS
     151    is_version_1=0
     152    is_version_1_4=0
     153
    151154    tables=$(mysql $rootuser $rootpass -s -N -Danalytics -e "show tables" 2>/dev/null || true)
    152155    if [ -n "$tables" ]; then
    153         tables=$(echo $tables|grep historico_clients||true)
    154         dump_old_data=yes
    155     else
    156         dump_old_data=no
    157     fi
    158     keys=$(mysqldump $rootuser $rootpass analytics 2>/dev/null|egrep '^[[:space:]]*KEY'|wc -l)
    159     dumpfile="/usr/lib/analytics-server/analytics-0_1_3-to-0_1_4.sql"
     156        tables=$(echo $tables|grep historico_clients || true)
     157        if [ -n "$tables" ]; then
     158            is_version_1_4=1
     159        else
     160            is_version_1=1
     161        fi
     162    fi
     163    if [ "$is_version_1" = "1" ]; then
     164        echo "Updating database from version 1"
     165        mysql $rootuser $rootpass < /usr/lib/analytics-server/migrate_from_1.sql || true
     166        create_db="no"
     167    fi
     168    if [ "$is_version_1_4" = "1" ]; then
     169        echo "Updating database from version 1.4"
     170        mysql $rootuser $rootpass < /usr/lib/analytics-server/migrate_from_1_4.sql || true
     171        create_db="no"
     172    fi
     173
     174    dumpfile="/usr/lib/analytics-server/analytics2.sql"
     175
     176    #keys=$(mysqldump $rootuser $rootpass analytics 2>/dev/null|egrep '^[[:space:]]*KEY'|wc -l)
     177    #dumpfile="/usr/lib/analytics-server/analytics-0_1_3-to-0_1_4.sql"
    160178
    161179    #UPDATE FROM 0.1.3 to 0.1.4
    162180
    163     older_version="$2"
    164     target_update="0.1.4"
    165 
    166     need_update_to_0_1_4=no
    167     dpkg --compare-versions "$older_version" lt "$target_update" && need_update_to_0_1_4=yes
    168     if [ -z "$tables" -o $keys -ne 12 ]; then
    169         need_update_to_0_1_4=yes
    170         echo "failed database test for table historico_clients or keys"
    171     fi
    172     if [ "x$need_update_to_0_1_4" = "xyes" ]; then
    173         echo Updating to database version upper than 0.1.4
    174         if [ "x$dump_old_data" = "xyes" ]; then
    175             mysqldump $rootuser $rootpass --no-create-info analytics > /tmp/__analytics_tmp__ 2>/dev/null
    176         fi
    177         mysql $rootuser $rootpass -s -N -e "drop database if exists analytics"
    178         mysql $rootuser $rootpass < $dumpfile
    179         mysql $rootuser $rootpass analytics < /tmp/__analytics_tmp__
    180     else
    181         echo "Seems that database is newer than 0.1.4, skipping database migration"
    182     fi
     181    #older_version="$2"
     182    #target_update="0.1.4"
     183
     184    #need_update_to_0_1_4=no
     185    #dpkg --compare-versions "$older_version" lt "$target_update" && need_update_to_0_1_4=yes
     186    #if [ -z "$tables" -o $keys -ne 12 ]; then
     187    #    need_update_to_0_1_4=yes
     188    #    echo "failed database test for table historico_clients or keys"
     189    #fi
     190    #if [ "x$need_update_to_0_1_4" = "xyes" ]; then
     191    #    echo Updating to database version upper than 0.1.4
     192    #    if [ "x$dump_old_data" = "xyes" ]; then
     193    #        mysqldump $rootuser $rootpass --no-create-info analytics > /tmp/__analytics_tmp__ 2>/dev/null
     194    #    fi
     195    #    mysql $rootuser $rootpass -s -N -e "drop database if exists analytics"
     196    #    mysql $rootuser $rootpass < $dumpfile
     197    #    mysql $rootuser $rootpass analytics < /tmp/__analytics_tmp__
     198    #else
     199    #    echo "Seems that database is newer than 0.1.4, skipping database migration"
     200    #fi
    183201
    184202
Note: See TracChangeset for help on using the changeset viewer.