mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
in devices table, replace devid and devtype with array so can track
history if/as they change; remove rrcount as no longer needed.
This commit is contained in:
parent
3499af3ac4
commit
de1f1cf681
2 changed files with 6 additions and 6 deletions
|
@ -395,7 +395,7 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
|||
} while ( DEVID_NONE == devID );
|
||||
|
||||
const char* command = "INSERT INTO " DEVICES_TABLE
|
||||
" (id, devType, devid, clntVers, versDesc, model, osvers)"
|
||||
" (id, devTypes[1], devids[1], clntVers, versDesc, model, osvers)"
|
||||
" VALUES( $1, $2, $3, $4, $5, $6, $7 )";
|
||||
int nParams = 7;
|
||||
char* paramValues[nParams];
|
||||
|
@ -435,7 +435,8 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host,
|
|||
// First update the existing
|
||||
StrWPF query;
|
||||
query.printf( "UPDATE " DEVICES_TABLE " SET "
|
||||
"rrcount = rrcount + 1, devType = %d, devid = '%s', ",
|
||||
"devTypes = array_prepend( %d, devTypes), "
|
||||
"devids = array_prepend('%s', devids), ",
|
||||
host->m_devIDType, host->m_devIDString.c_str() );
|
||||
|
||||
formatUpdate( query, desc, clientVersion, model, osVers, relayID );
|
||||
|
@ -888,7 +889,7 @@ DBMgr::getDevID( const DevID* devID )
|
|||
}
|
||||
} else if ( 0 < devID->m_devIDString.size() ) {
|
||||
query.printf( "SELECT id FROM " DEVICES_TABLE
|
||||
" WHERE devtype=%d and devid = '%s'"
|
||||
" WHERE devtypes[1]=%d and devids[1] = '%s'"
|
||||
" ORDER BY ctime DESC LIMIT 1",
|
||||
devIDType, devID->m_devIDString.c_str() );
|
||||
}
|
||||
|
|
|
@ -81,11 +81,10 @@ EOF
|
|||
cat | psql $DBNAME --file - <<EOF
|
||||
CREATE TABLE devices (
|
||||
id INTEGER UNIQUE PRIMARY KEY
|
||||
,devType INTEGER
|
||||
,devTypes INTEGER[]
|
||||
,devids TEXT[]
|
||||
,clntVers INTEGER
|
||||
,rrcount INTEGER DEFAULT 0
|
||||
,versDesc TEXT
|
||||
,devid TEXT
|
||||
,model TEXT
|
||||
,osvers TEXT
|
||||
,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
|
|
Loading…
Reference in a new issue