2025-04-07 Fred Gleason <fredg@paravelsystems.com>

* Dropped the 'RDAIRPLAY.INSTANCE' field from the database.
	* Incremented the database version to 376.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2025-04-07 14:26:05 -04:00
parent 54559331d0
commit 5ebf964f48
5 changed files with 66 additions and 1 deletions

View File

@ -24970,3 +24970,6 @@
2025-03-19 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'hpiplayout-test' test harness that caused the
build to fail when HPI support was disabled.
2025-04-07 Fred Gleason <fredg@paravelsystems.com>
* Dropped the 'RDAIRPLAY.INSTANCE' field from the database.
* Incremented the database version to 376.

View File

@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 375
#define RD_VERSION_DATABASE 376
#endif // DBVERSION_H

View File

@ -40,6 +40,25 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg)
// NEW SCHEMA REVERSIONS GO HERE...
//
// Revert 376
//
if((cur_schema == 376) && (set_schema < cur_schema))
{
DropIndex("RDAIRPLAY","STATION_IDX");
sql=QString("alter table `RDAIRPLAY` ")+
"add column `INSTANCE` int unsigned after `STATION`";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("alter table `RDAIRPLAY` add index `STATION_IDX` (`STATION`,`INSTANCE`)");
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
WriteSchemaVersion(--cur_schema);
}
//
// Revert 375
//

View File

@ -164,6 +164,7 @@ void MainObject::InitializeSchemaMap() {
global_version_map["4.1"]=371;
global_version_map["4.2"]=374;
global_version_map["4.3"]=375;
global_version_map["4.4"]=376;
}

View File

@ -18,6 +18,8 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <QMultiMap>
#include <rdcart.h>
#include <rdconf.h>
#include <rddb.h>
@ -11853,6 +11855,46 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
WriteSchemaVersion(++cur_schema);
}
if((cur_schema<376)&&(set_schema>cur_schema)) {
//
// De-duplicate Host Entries
//
QMultiMap<QString,int> id_map;
sql=QString("select ")+
"`STATION`,"+ // 00
"`ID` "+ // 01
"from `RDAIRPLAY`";
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
id_map.insert(q->value(0).toString(),q->value(1).toInt());
}
delete q;
QStringList keys=id_map.uniqueKeys();
for(int i=0;i<keys.size();i++) {
QList<int> ids=id_map.values(keys.at(i));
for(int j=1;j<ids.size();j++) {
sql=QString("delete from `RDAIRPLAY` where ")+
QString::asprintf("`ID`=%d",ids.at(j));
fprintf(stderr,"deleting duplicate RDAIRPLAY entry %d:\"%s\"\n",
ids.at(j),keys.at(i).toUtf8().constData());
RDSqlQuery::apply(sql);
}
}
//
// Apply Schema Change
//
DropIndex("RDAIRPLAY","STATION_IDX");
DropColumn("RDAIRPLAY","INSTANCE");
sql=QString("alter table `RDAIRPLAY` ")+
"add unique index `STATION_IDX` (`STATION`)";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
WriteSchemaVersion(++cur_schema);
}
// NEW SCHEMA UPDATES GO HERE...