|
31 | 31 | #include "../msbuild/WindowsHelper.h"
|
32 | 32 | #endif
|
33 | 33 |
|
34 |
| -#define DB_VERSION 101 |
| 34 | +#define DB_VERSION 102 |
35 | 35 |
|
36 | 36 | extern http::server::CWebServerHelper m_webservers;
|
37 | 37 | extern std::string szWWWFolder;
|
@@ -724,24 +724,43 @@ bool CSQLHelper::OpenDatabase()
|
724 | 724 | query(sqlCreateUserSessions);
|
725 | 725 | query(sqlCreateMobileDevices);
|
726 | 726 | //Add indexes to log tables
|
727 |
| - query("create index if not exists f_idx on Fan(DeviceRowID);"); |
728 |
| - query("create index if not exists fc_idx on Fan_Calendar(DeviceRowID);"); |
729 |
| - query("create index if not exists l_idx on LightingLog(DeviceRowID);"); |
730 |
| - query("create index if not exists s_idx on SceneLog(SceneRowID);"); |
731 |
| - query("create index if not exists m_idx on Meter(DeviceRowID);"); |
732 |
| - query("create index if not exists mc_idx on Meter_Calendar(DeviceRowID);"); |
733 |
| - query("create index if not exists mm_idx on MultiMeter(DeviceRowID);"); |
734 |
| - query("create index if not exists mmc_idx on MultiMeter_Calendar(DeviceRowID);"); |
735 |
| - query("create index if not exists p_idx on Percentage(DeviceRowID);"); |
736 |
| - query("create index if not exists pc_idx on Percentage_Calendar(DeviceRowID);"); |
737 |
| - query("create index if not exists r_idx on Rain(DeviceRowID);"); |
738 |
| - query("create index if not exists rc_idx on Rain_Calendar(DeviceRowID);"); |
739 |
| - query("create index if not exists t_idx on Temperature(DeviceRowID);"); |
740 |
| - query("create index if not exists tc_idx on Temperature_Calendar(DeviceRowID);"); |
741 |
| - query("create index if not exists u_idx on UV(DeviceRowID);"); |
742 |
| - query("create index if not exists uv_idx on UV_Calendar(DeviceRowID);"); |
743 |
| - query("create index if not exists w_idx on Wind(DeviceRowID);"); |
744 |
| - query("create index if not exists wc_idx on Wind_Calendar(DeviceRowID);"); |
| 727 | + query("create index if not exists ds_hduts_idx on DeviceStatus(HardwareID, DeviceID, Unit, Type, SubType);"); |
| 728 | + query("create index if not exists f_id_idx on Fan(DeviceRowID);"); |
| 729 | + query("create index if not exists f_id_date_idx on Fan(DeviceRowID, Date);"); |
| 730 | + query("create index if not exists fc_id_idx on Fan_Calendar(DeviceRowID);"); |
| 731 | + query("create index if not exists fc_id_date_idx on Fan_Calendar(DeviceRowID, Date);"); |
| 732 | + query("create index if not exists ll_id_idx on LightingLog(DeviceRowID);"); |
| 733 | + query("create index if not exists ll_id_date_idx on LightingLog(DeviceRowID, Date);"); |
| 734 | + query("create index if not exists sl_id_idx on SceneLog(SceneRowID);"); |
| 735 | + query("create index if not exists sl_id_date_idx on SceneLog(SceneRowID, Date);"); |
| 736 | + query("create index if not exists m_id_idx on Meter(DeviceRowID);"); |
| 737 | + query("create index if not exists m_id_date_idx on Meter(DeviceRowID, Date);"); |
| 738 | + query("create index if not exists mc_id_idx on Meter_Calendar(DeviceRowID);"); |
| 739 | + query("create index if not exists mc_id_date_idx on Meter_Calendar(DeviceRowID, Date);"); |
| 740 | + query("create index if not exists mm_id_idx on MultiMeter(DeviceRowID);"); |
| 741 | + query("create index if not exists mm_id_date_idx on MultiMeter(DeviceRowID, Date);"); |
| 742 | + query("create index if not exists mmc_id_idx on MultiMeter_Calendar(DeviceRowID);"); |
| 743 | + query("create index if not exists mmc_id_date_idx on MultiMeter_Calendar(DeviceRowID, Date);"); |
| 744 | + query("create index if not exists p_id_idx on Percentage(DeviceRowID);"); |
| 745 | + query("create index if not exists p_id_date_idx on Percentage(DeviceRowID, Date);"); |
| 746 | + query("create index if not exists pc_id_idx on Percentage_Calendar(DeviceRowID);"); |
| 747 | + query("create index if not exists pc_id_date_idx on Percentage_Calendar(DeviceRowID, Date);"); |
| 748 | + query("create index if not exists r_id_idx on Rain(DeviceRowID);"); |
| 749 | + query("create index if not exists r_id_date_idx on Rain(DeviceRowID, Date);"); |
| 750 | + query("create index if not exists rc_id_idx on Rain_Calendar(DeviceRowID);"); |
| 751 | + query("create index if not exists rc_id_date_idx on Rain_Calendar(DeviceRowID, Date);"); |
| 752 | + query("create index if not exists t_id_idx on Temperature(DeviceRowID);"); |
| 753 | + query("create index if not exists t_id_date_idx on Temperature(DeviceRowID, Date);"); |
| 754 | + query("create index if not exists tc_id_idx on Temperature_Calendar(DeviceRowID);"); |
| 755 | + query("create index if not exists tc_id_date_idx on Temperature_Calendar(DeviceRowID, Date);"); |
| 756 | + query("create index if not exists u_id_idx on UV(DeviceRowID);"); |
| 757 | + query("create index if not exists u_id_date_idx on UV(DeviceRowID, Date);"); |
| 758 | + query("create index if not exists uv_id_idx on UV_Calendar(DeviceRowID);"); |
| 759 | + query("create index if not exists uv_id_date_idx on UV_Calendar(DeviceRowID, Date);"); |
| 760 | + query("create index if not exists w_id_idx on Wind(DeviceRowID);"); |
| 761 | + query("create index if not exists w_id_date_idx on Wind(DeviceRowID, Date);"); |
| 762 | + query("create index if not exists wc_id_idx on Wind_Calendar(DeviceRowID);"); |
| 763 | + query("create index if not exists wc_id_date_idx on Wind_Calendar(DeviceRowID, Date);"); |
745 | 764 |
|
746 | 765 | if ((!bNewInstall) && (dbversion < DB_VERSION))
|
747 | 766 | {
|
@@ -1936,6 +1955,66 @@ bool CSQLHelper::OpenDatabase()
|
1936 | 1955 | }
|
1937 | 1956 | }
|
1938 | 1957 | }
|
| 1958 | + if (dbversion < 102) |
| 1959 | + { |
| 1960 | + // Remove old indexes |
| 1961 | + query("drop index if exists f_idx;"); |
| 1962 | + query("drop index if exists fc_idx;"); |
| 1963 | + query("drop index if exists l_idx;"); |
| 1964 | + query("drop index if exists s_idx;"); |
| 1965 | + query("drop index if exists m_idx;"); |
| 1966 | + query("drop index if exists mc_idx;"); |
| 1967 | + query("drop index if exists mm_idx;"); |
| 1968 | + query("drop index if exists mmc_idx;"); |
| 1969 | + query("drop index if exists p_idx;"); |
| 1970 | + query("drop index if exists pc_idx;"); |
| 1971 | + query("drop index if exists r_idx;"); |
| 1972 | + query("drop index if exists rc_idx;"); |
| 1973 | + query("drop index if exists t_idx;"); |
| 1974 | + query("drop index if exists tc_idx;"); |
| 1975 | + query("drop index if exists u_idx;"); |
| 1976 | + query("drop index if exists uv_idx;"); |
| 1977 | + query("drop index if exists w_idx;"); |
| 1978 | + query("drop index if exists wc_idx;"); |
| 1979 | + // Add new indexes |
| 1980 | + query("create index if not exists ds_hduts_idx on DeviceStatus(HardwareID, DeviceID, Unit, Type, SubType);"); |
| 1981 | + query("create index if not exists f_id_idx on Fan(DeviceRowID);"); |
| 1982 | + query("create index if not exists f_id_date_idx on Fan(DeviceRowID, Date);"); |
| 1983 | + query("create index if not exists fc_id_idx on Fan_Calendar(DeviceRowID);"); |
| 1984 | + query("create index if not exists fc_id_date_idx on Fan_Calendar(DeviceRowID, Date);"); |
| 1985 | + query("create index if not exists ll_id_idx on LightingLog(DeviceRowID);"); |
| 1986 | + query("create index if not exists ll_id_date_idx on LightingLog(DeviceRowID, Date);"); |
| 1987 | + query("create index if not exists sl_id_idx on SceneLog(SceneRowID);"); |
| 1988 | + query("create index if not exists sl_id_date_idx on SceneLog(SceneRowID, Date);"); |
| 1989 | + query("create index if not exists m_id_idx on Meter(DeviceRowID);"); |
| 1990 | + query("create index if not exists m_id_date_idx on Meter(DeviceRowID, Date);"); |
| 1991 | + query("create index if not exists mc_id_idx on Meter_Calendar(DeviceRowID);"); |
| 1992 | + query("create index if not exists mc_id_date_idx on Meter_Calendar(DeviceRowID, Date);"); |
| 1993 | + query("create index if not exists mm_id_idx on MultiMeter(DeviceRowID);"); |
| 1994 | + query("create index if not exists mm_id_date_idx on MultiMeter(DeviceRowID, Date);"); |
| 1995 | + query("create index if not exists mmc_id_idx on MultiMeter_Calendar(DeviceRowID);"); |
| 1996 | + query("create index if not exists mmc_id_date_idx on MultiMeter_Calendar(DeviceRowID, Date);"); |
| 1997 | + query("create index if not exists p_id_idx on Percentage(DeviceRowID);"); |
| 1998 | + query("create index if not exists p_id_date_idx on Percentage(DeviceRowID, Date);"); |
| 1999 | + query("create index if not exists pc_id_idx on Percentage_Calendar(DeviceRowID);"); |
| 2000 | + query("create index if not exists pc_id_date_idx on Percentage_Calendar(DeviceRowID, Date);"); |
| 2001 | + query("create index if not exists r_id_idx on Rain(DeviceRowID);"); |
| 2002 | + query("create index if not exists r_id_date_idx on Rain(DeviceRowID, Date);"); |
| 2003 | + query("create index if not exists rc_id_idx on Rain_Calendar(DeviceRowID);"); |
| 2004 | + query("create index if not exists rc_id_date_idx on Rain_Calendar(DeviceRowID, Date);"); |
| 2005 | + query("create index if not exists t_id_idx on Temperature(DeviceRowID);"); |
| 2006 | + query("create index if not exists t_id_date_idx on Temperature(DeviceRowID, Date);"); |
| 2007 | + query("create index if not exists tc_id_idx on Temperature_Calendar(DeviceRowID);"); |
| 2008 | + query("create index if not exists tc_id_date_idx on Temperature_Calendar(DeviceRowID, Date);"); |
| 2009 | + query("create index if not exists u_id_idx on UV(DeviceRowID);"); |
| 2010 | + query("create index if not exists u_id_date_idx on UV(DeviceRowID, Date);"); |
| 2011 | + query("create index if not exists uv_id_idx on UV_Calendar(DeviceRowID);"); |
| 2012 | + query("create index if not exists uv_id_date_idx on UV_Calendar(DeviceRowID, Date);"); |
| 2013 | + query("create index if not exists w_id_idx on Wind(DeviceRowID);"); |
| 2014 | + query("create index if not exists w_id_date_idx on Wind(DeviceRowID, Date);"); |
| 2015 | + query("create index if not exists wc_id_idx on Wind_Calendar(DeviceRowID);"); |
| 2016 | + query("create index if not exists wc_id_date_idx on Wind_Calendar(DeviceRowID, Date);"); |
| 2017 | + } |
1939 | 2018 | }
|
1940 | 2019 | else if (bNewInstall)
|
1941 | 2020 | {
|
|
0 commit comments