You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/app/qgisapp.cpp
+58-1
Original file line number
Diff line number
Diff line change
@@ -2056,7 +2056,64 @@ bool QgisApp::createDB()
2056
2056
returnFALSE;
2057
2057
}
2058
2058
}
2059
-
returnTRUE;
2059
+
else
2060
+
{
2061
+
// migrate if necessary
2062
+
sqlite3 *db;
2063
+
if ( sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().constData(), &db ) != SQLITE_OK )
2064
+
{
2065
+
QMessageBox::critical( this, tr( "Private qgis.db" ), tr( "Could not open qgis.db" ) );
2066
+
returnfalse;
2067
+
}
2068
+
2069
+
char *errmsg;
2070
+
int res = sqlite3_exec( db, "SELECT epsg FROM tbl_srs LIMIT 0", 0, 0, &errmsg );
2071
+
if ( res == SQLITE_OK )
2072
+
{
2073
+
// epsg column exists => need migration
2074
+
if ( sqlite3_exec( db,
2075
+
"ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2076
+
"CREATE TABLE tbl_srs ("
2077
+
"srs_id INTEGER PRIMARY KEY,"
2078
+
"description text NOT NULL,"
2079
+
"projection_acronym text NOT NULL,"
2080
+
"ellipsoid_acronym NOT NULL,"
2081
+
"parameters text NOT NULL,"
2082
+
"srid integer,"
2083
+
"auth_name varchar,"
2084
+
"auth_id varchar,"
2085
+
"is_geo integer NOT NULL,"
2086
+
"deprecated boolean);"
2087
+
"CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2088
+
"DROP VIEW vw_srs;"
2089
+
"CREATE VIEW vw_srs as "
2090
+
"select a.description as description,"
2091
+
"a.srs_id as srs_id,"
2092
+
"a.is_geo as is_geo,"
2093
+
"b.name as name,"
2094
+
"a.parameters as parameters,"
2095
+
"a.auth_name as auth_name,"
2096
+
"a.auth_id as auth_id,"
2097
+
"a.deprecated as deprecated"
2098
+
" from "
2099
+
"tbl_srs a inner join tbl_projection b on a.projection_acronym=b.acronym"
2100
+
" order by "
2101
+
"b.name,"
2102
+
"a.description;"
2103
+
"INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
0 commit comments