Rivendellaudio/utils/rddbmgr/schemamap.cpp
Fred Gleason a564d0c0fc 2018-10-03 Fred Gleason <fredg@paravelsystems.com>
* Changed all instances of 'char' to 'varchar' in the database.
	* Changed the width of the 'CART.TITLE' field to 191.
	* Changed the width of the 'CART.ARTIST' field to 191.
	* Changed the width of the 'CART.ALBUM' field to 191.
	* Changed the width of the 'CART.USER_DEFINED' field to 191.
	* Changed the width of the 'CUTS.ORIGIN_LOGIN_NAME' field to 191.
	* Changed the width of the 'DROPBOXES.PATH' field to 191.
	* Changed the width of the 'DROPBOXES.LOG_PATH' field to 191.
	* Changed the width of the 'DROPBOXES.SET_USER_DEFINED' field to 191.
	* Changed the width of the 'DROPBOX_PATHS.FILE_PATH' field to 191.
	* Changed the width of the 'ELR_LINES.TITLE' field to 191.
	* Changed the width of the 'ELR_LINES.ARTIST' field to 191.
	* Changed the width of the 'ELR_LINES.USER_DEFINED' field to 191.
	* Changed the width of the 'ELR_LINES.ALBUM' field to 191.
	* Changed the width of the 'ENCODERS.COMMAND_LINE' field to 191.
	* Changed the width of the 'EVENTS.NOTE_TEXT' field to 191.
	* Changed the width of the 'EVENT_LINES.MARKER_COMMENT' field to 191.
	* Changed the width of the 'FEEDS.CHANNEL_TITLE' field to 191.
	* Changed the width of the 'FEEDS.CHANNEL_LINK' field to 191.
	* Changed the width of the 'FEEDS.BASE_URL' field to 191.
	* Changed the width of the 'FEEDS.BASE_PREAMBLE' field to 191.
	* Changed the width of the 'FEEDS.PURGE_URL' field to 191.
	* Changed the width of the 'FEEDS.REDIRECT_PATH' field to 191.
	* Changed the width of the 'FEED_PERMS.USER_NAME' field to 191.
	* Changed the width of the 'GROUPS.DESCRIPTION' field to 191.
	* Changed the width of the 'GROUPS.DEFAULT_TITLE' field to 191.
	* Changed the width of the 'HOSTVARS.VARVALUE' field to 191.
	* Changed the width of the 'HOSTVARS.REMARK' field to 191.
	* Changed the width of the 'IMPORTER_LINES.TITLE' field to 191.
	* Changed the width of the 'IMPORTER_LINES.TRACK_STRING' field to 191.
	* Changed the width of the 'INPUTS.NODE_HOSTNAME' field to 191.
	* Changed the width of the 'LOGS.ORIGIN_USER' field to 191.
	* Changed the width of the 'LOGS.LOCK_USER_NAME' field to 191.
	* Changed the width of the 'LOG_LINES.COMMENT' field to 191.
	* Changed the width of the 'LOG_LINES.ORIGIN_USER' field to 191.
	* Changed the width of the 'LOG_MACHINES.UDP_ADDR' field to 191.
	* Changed the width of the 'LOG_MACHINES.UDP_STRING' field to 191.
	* Changed the width of the 'LOG_MACHINES.LOG_RML' field to 191.
	* Changed the width of the 'MATRICES.GPIO_DEVICE' field to 191.
	* Changed the width of the 'NOWNEXT_PLUGINS.PLUGIN_PATH' field to 191.
	* Changed the width of the 'NOWNEXT_PLUGINS.PLUGIN_ARG' field to 191.
	* Changed the width of the 'OUTPUTS.NODE_HOSTNAME' field to 191.
	* Changed the width of the 'PODCASTS.ITEM_TITLE' field to 191.
	* Changed the width of the 'PODCASTS.ITEM_LINK' field to 191.
	* Changed the width of the 'PODCASTS.ITEM_COMMENTS' field to 191.
	* Changed the width of the 'PODCASTS.ITEM_AUTHOR' field to 191.
	* Changed the width of the 'PODCASTS.ITEM_SOURCE_URL' field to 191.
	* Changed the width of the 'PODCASTS.AUDIO_FILENAME' field to 191.
	* Changed the width of the 'RDAIRPLAY.SKIN_PATH' field to 191.
	* Changed the width of the 'RDAIRPLAY_CHANNELS.START_RML' field to 191.
	* Changed the width of the 'RDAIRPLAY_CHANNELS.STOP_RML' field to 191.
	* Changed the width of the 'RDCATCH.ERROR_RML' field to 191.
	* Changed the width of the 'RDPANEL.SKIN_PATH' field to 191.
	* Changed the width of the 'RDPANEL_CHANNELS.START_RML' field to 191.
	* Changed the width of the 'RDPANEL_CHANNELS.STOP_RML' field to 191.
	* Changed the width of the 'RECORDINGS.URL' field to 191.
	* Changed the width of the 'REPLICATORS.URL' field to 191.
	* Changed the width of the 'REPL_CART_STATE.POSTED_FILENAME' field
	to 191.
	* Changed the width of the 'REPORTS.EXPORT_PATH' field to 191.
	* Changed the width of the 'REPORTS.WIN_EXPORT_PATH' field to 191.
	* Changed the width of the 'SERVICES.DESCRIPTION' field to 191.
	* Changed the width of the 'SERVICES.NAME_TEMPLATE' field to 191.
	* Changed the width of the 'SERVICES.DESCRIPTION_TEMPLATE' field to 191.
	* Changed the width of the 'SERVICES.PROGRAM_CODE' field to 191.
	* Changed the width of the 'SERVICES.TFC_PATH' field to 191.
	* Changed the width of the 'SERVICES.TFC_WIN_PATH' field to 191.
	* Changed the width of the 'SERVICES.MUS_PATH' field to 191.
	* Changed the width of the 'SERVICES_MUS_WIN_PATH' field to 191.
	* Changed the width of the 'STATIONS.USER_NAME' field to 191.
	* Changed the width of the 'STATIONS.DEFAULT_NAME' field to 191.
	* Changed the width of the 'STATIONS.EDITOR_PATH' field to 191.
	* Changed the width of the 'STATIONS.JACK_COMMAND_LINE' field to 191.
	* Changed the width of the 'SWITCHER_NODES.DESCRIPTION' field to 191.
	* Changed the width of the 'SYSTEM.ISCI_XREFERENCE_PATH' field to 191.
	* Changed the width of the 'USERS.LOGIN_NAME' field to 191.
	* Changed the width of the 'USERS.FULL_NAME' field to 191.
	* Changed the width of the 'USERS.DESCRIPTION' field to 191.
	* Changed the width of the 'USER_PERMS.USER_NAME' field to 191.
	* Changed the width of the 'USER_SERVICE_PERMS.USER_NAME' field to 191.
	* Changed the width of the 'WEBAPI_AUTHS.LOGIN_NAME' field to 191.
	* Changed the width of the 'WEB_CONNECTIONS.LOGIN_NAME' field to 191.
	* Incremented the database version to 297.
	* Changed the default DB charset to 'utf8mb4'.
	* Changed the default DB collation to 'utf8mb4_general_ci'.
	* Removed the MYSQL_BUILTIN_DATABASE define from 'lib/rd.h'.
	* Removed the POSTGRESQL_BUILTIN_DATABASE define from 'lib/rd.h'.
2018-10-03 18:13:51 -04:00

197 lines
4.2 KiB
C++

// schemamap.cpp
//
// DB schema version <==> Rivendell version map
//
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qmap.h>
#include <qstringlist.h>
#include "rddbmgr.h"
class VersionString : public QString
{
public:
VersionString();
VersionString(const char *str);
int major() const;
int minor() const;
int point() const;
bool operator<(const VersionString &rhs) const;
bool operator==(const VersionString &rhs) const;
private:
int ver_major;
int ver_minor;
int ver_point;
};
VersionString::VersionString()
: QString()
{
ver_major=0;
ver_minor=0;
ver_point=0;
}
VersionString::VersionString(const char *str)
: QString(str)
{
QStringList f0=f0.split(".",str);
ver_major=f0[0].toInt();
if(f0.size()>=2) {
ver_minor=f0[1].toInt();
if(f0.size()>=3) {
ver_point=f0[2].toInt();
}
}
}
int VersionString::major() const
{
return ver_major;
}
int VersionString::minor() const
{
return ver_minor;
}
int VersionString::point() const
{
return ver_point;
}
bool VersionString::operator<(const VersionString &rhs) const
{
if(major()<rhs.major()) {
return true;
}
if(major()>rhs.major()) {
return false;
}
if(minor()<rhs.minor()) {
return true;
}
if(minor()>rhs.minor()) {
return false;
}
return false;
}
bool VersionString::operator==(const VersionString &rhs) const
{
return (major()==rhs.major())&&(minor()==rhs.minor());
}
//
// Version -> Schema Map
//
QMap<VersionString,int> global_version_map;
void MainObject::InitializeSchemaMap() {
global_version_map["1.0"]=159;
global_version_map["1.1"]=162;
global_version_map["1.2"]=169;
global_version_map["1.3"]=173;
global_version_map["1.4"]=177;
global_version_map["1.5"]=179;
global_version_map["1.6"]=182;
global_version_map["1.7"]=186;
global_version_map["2.0"]=202;
global_version_map["2.1"]=205;
global_version_map["2.2"]=207;
global_version_map["2.3"]=213;
global_version_map["2.4"]=216;
global_version_map["2.5"]=220;
global_version_map["2.6"]=224;
global_version_map["2.7"]=231;
global_version_map["2.8"]=234;
global_version_map["2.9"]=239;
global_version_map["2.10"]=242;
global_version_map["2.11"]=245;
global_version_map["2.12"]=254;
global_version_map["2.13"]=255;
global_version_map["2.14"]=258;
global_version_map["2.15"]=259;
global_version_map["2.16"]=263;
global_version_map["2.17"]=268;
global_version_map["2.18"]=272;
global_version_map["2.19"]=275;
global_version_map["3.0"]=297;
}
int MainObject::GetVersionSchema(const QString &ver) const
{
QString version=ver;
bool ok=false;
//
// Normalize String
//
if(version.left(1).lower()=="v") {
version=version.right(version.length()-1);
}
QStringList f0=f0.split(".",version);
if(f0.size()!=3) {
return 0;
}
for(int i=0;i<3;i++) {
f0[i].toInt(&ok);
if(!ok) {
return 0;
}
}
//
// Lookup Schema
//
if(global_version_map.count(VersionString(f0[0]+"."+f0[1]))==0) {
return 0;
}
return global_version_map.value(VersionString(f0[0]+"."+f0[1]));
}
QString MainObject::GetSchemaVersion(int schema) const
{
QString prev_version="_preproduction";
for(QMap<VersionString,int>::const_iterator it=global_version_map.begin();
it!=global_version_map.end();it++) {
if(it.data()==schema) {
return "v"+it.key()+".x";
}
if(it.data()>schema) {
return tr("between")+" v"+prev_version+".x "+tr("and")+
" v"+it.key()+".x";
}
prev_version=it.key();
}
return QString("after")+" v"+prev_version+".x";
}