mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-14 08:39:31 +02:00
2016-03-28 Fred Gleason <fredg@paravelsystems.com>
* Added an rdrevert(8) commmand in 'utils/rdrevert/'.
This commit is contained in:
parent
e656a4bb0a
commit
3aac0356dd
1
.gitignore
vendored
1
.gitignore
vendored
@ -96,5 +96,6 @@ utils/rdimport/rdimport
|
||||
utils/rdcollect/rdcollect
|
||||
utils/rdmaint/rdmaint
|
||||
utils/rdgen/rdgen
|
||||
utils/rdrevert/rdrevert
|
||||
utils/sas_shim/sas_shim
|
||||
web/rdfeed/rdfeed.xml
|
||||
|
@ -15031,3 +15031,5 @@
|
||||
2016-03-25 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'Show Only Recent Logs' checkbox in 'rdlogedit/rdlogedit.cpp'
|
||||
and 'rdlogedit/rdlogedit.h'.
|
||||
2016-03-28 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added an rdrevert(8) commmand in 'utils/rdrevert/'.
|
||||
|
@ -466,6 +466,7 @@ AC_CONFIG_FILES([rivendell.spec \
|
||||
utils/rdmarkerset/Makefile \
|
||||
utils/rdpopup/Makefile \
|
||||
utils/rdpurgecasts/Makefile \
|
||||
utils/rdrevert/Makefile \
|
||||
utils/rdsoftkeys/Makefile \
|
||||
utils/rmlsend/Makefile \
|
||||
utils/sas_shim/Makefile \
|
||||
|
@ -33,12 +33,18 @@
|
||||
|
||||
all-local: cae.html\
|
||||
cae.pdf\
|
||||
rdrevert.8\
|
||||
rdrevert.xml\
|
||||
web_api.html\
|
||||
web_api.pdf
|
||||
|
||||
man_MANS = rdrevert.8
|
||||
|
||||
EXTRA_DIST = cae.html\
|
||||
cae.pdf\
|
||||
cae.xml\
|
||||
rdrevert.8\
|
||||
rdrevert.xml\
|
||||
web_api.html\
|
||||
web_api.pdf\
|
||||
web_api.xml
|
||||
|
84
docs/docbook/rdrevert.xml
Normal file
84
docs/docbook/rdrevert.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
|
||||
<!--
|
||||
Header
|
||||
-->
|
||||
<refmeta>
|
||||
<refentrytitle>rdrevert</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
<refmiscinfo class='source'>March 2016</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>rdrevert</refname>
|
||||
<refpurpose>Revert a Rivendell database to a previous schema version</refpurpose>
|
||||
</refnamediv>
|
||||
<info>
|
||||
<author>
|
||||
<personname>
|
||||
<firstname>Fred</firstname>
|
||||
<surname>Gleason</surname>
|
||||
<email>fredg@paravelsystems.com</email>
|
||||
</personname>
|
||||
<contrib>Application Author</contrib>
|
||||
</author>
|
||||
</info>
|
||||
|
||||
<!--
|
||||
Body
|
||||
-->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>rdrevert</command>
|
||||
<arg choice='opt'><replaceable>OPTIONS</replaceable></arg>
|
||||
<arg choice='opt'><userinput>--set-schema=</userinput><replaceable>schema</replaceable></arg>
|
||||
<arg choice='opt'><userinput>--set-version=</userinput><replaceable>version</replaceable></arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'><title>Description</title>
|
||||
<para>
|
||||
<command>rdrevert</command><manvolnum>8</manvolnum> can be used to revert
|
||||
the schema of a Rivendell database to an earlier version, specified as
|
||||
either a Rivendell version string or an absolute schema version number.
|
||||
If no arguments are given, <command>rdrevert</command><manvolnum>8</manvolnum>
|
||||
will print the current database schema version to standard output and
|
||||
then exit.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'><title>Options</title>
|
||||
<variablelist remap='TP'>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--set-schema=</option><replaceable>schema</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Set the version number of the schema to which to revert.
|
||||
<command>rdrevert</command><manvolnum>8</manvolnum> can revert back
|
||||
up to schema version 242 (v2.10.0) inclusive. Attempting to
|
||||
revert to an earlier schema than 242 will generate an
|
||||
<computeroutput>unsupported schema</computeroutput> error.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--set-version=</option><replaceable>version</replaceable>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Determine the schema to which to revert on the basis of the
|
||||
specified Rivendell version --e.g. <userinput>2.10.3</userinput>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
@ -286,6 +286,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/etc/security/console.apps/rdalsaconfig-root
|
||||
%{_mandir}/man1/rdimport.1.gz
|
||||
%{_mandir}/man8/rdmarkerset.8.gz
|
||||
%{_mandir}/man8/rdrevert.8.gz
|
||||
%doc AUTHORS
|
||||
%doc ChangeLog
|
||||
%doc COPYING
|
||||
|
@ -2,9 +2,7 @@
|
||||
##
|
||||
## Automake.am for rivendell/utils
|
||||
##
|
||||
## (C) Copyright 2002-2005 Fred Gleason <fredg@paravelsystems.com>
|
||||
##
|
||||
## $Id: Makefile.am,v 1.54.8.6 2014/01/16 02:44:59 cvs Exp $
|
||||
## (C) Copyright 2002-2016 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 as
|
||||
@ -45,8 +43,9 @@ SUBDIRS = $(ALSACONFIG_RD_OPT)\
|
||||
rdmarkerset\
|
||||
rdpopup\
|
||||
rdpurgecasts\
|
||||
rmlsend\
|
||||
rdrevert\
|
||||
rdsoftkeys\
|
||||
rmlsend\
|
||||
sas_shim
|
||||
|
||||
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib
|
||||
|
50
utils/rdrevert/Makefile.am
Normal file
50
utils/rdrevert/Makefile.am
Normal file
@ -0,0 +1,50 @@
|
||||
## automake.am
|
||||
##
|
||||
## Automake.am for rivendell/utils/rdrevert
|
||||
##
|
||||
## (C) Copyright 2016 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.
|
||||
##
|
||||
## Use automake to process this into a Makefile.in
|
||||
|
||||
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib
|
||||
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
|
||||
MOC = @QT_MOC@
|
||||
|
||||
# The dependency for qt's Meta Object Compiler (moc)
|
||||
moc_%.cpp: %.h
|
||||
$(MOC) $< -o $@
|
||||
|
||||
sbin_PROGRAMS = rdrevert
|
||||
|
||||
dist_rdrevert_SOURCES = rdrevert.cpp rdrevert.h
|
||||
|
||||
rdrevert_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
|
||||
|
||||
CLEANFILES = *~\
|
||||
*.exe\
|
||||
*.idb\
|
||||
*ilk\
|
||||
*.obj\
|
||||
*.pdb\
|
||||
*.qm\
|
||||
moc_*
|
||||
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
*.tar.gz\
|
||||
aclocal.m4\
|
||||
configure\
|
||||
Makefile.in\
|
||||
moc_*
|
339
utils/rdrevert/rdrevert.cpp
Normal file
339
utils/rdrevert/rdrevert.cpp
Normal file
@ -0,0 +1,339 @@
|
||||
// rdrevert.cpp
|
||||
//
|
||||
// Revert the Rivendell database schema to an earlier version.
|
||||
//
|
||||
// (C) Copyright 2016 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <rdcmd_switch.h>
|
||||
|
||||
#include "rdrevert.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent,const char *name)
|
||||
:QObject(parent,name)
|
||||
{
|
||||
bool ok=false;
|
||||
int set_schema=0;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=
|
||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcollect",RDREVERT_USAGE);
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)=="--set-schema") {
|
||||
set_schema=cmd->value(i).toInt(&ok);
|
||||
if((!ok)||(set_schema<0)) {
|
||||
fprintf(stderr,"rdrevert: invalid schema value\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--set-version") {
|
||||
if((set_schema=MapSchema(cmd->value(i)))==0) {
|
||||
fprintf(stderr,"rdrevert: invalid/unsupported Rivendell version\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
if(!cmd->allProcessed()) {
|
||||
fprintf(stderr,"rdrevert: unknown option\n");
|
||||
exit(256);
|
||||
}
|
||||
|
||||
//
|
||||
// Load Local Configs
|
||||
//
|
||||
rev_config=new RDConfig();
|
||||
rev_config->load();
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
rev_db=QSqlDatabase::addDatabase(rev_config->mysqlDriver());
|
||||
if(!rev_db) {
|
||||
fprintf(stderr,"rdrevert: unable to connect to mysql server\n");
|
||||
exit(256);
|
||||
}
|
||||
rev_db->setDatabaseName(rev_config->mysqlDbname());
|
||||
rev_db->setUserName(rev_config->mysqlUsername());
|
||||
rev_db->setPassword(rev_config->mysqlPassword());
|
||||
rev_db->setHostName(rev_config->mysqlHostname());
|
||||
if(!rev_db->open()) {
|
||||
fprintf(stderr,"rdrevert: unable to authenticate with mysql server\n");
|
||||
rev_db->removeDatabase(rev_config->mysqlDbname());
|
||||
exit(256);
|
||||
}
|
||||
|
||||
int start_schema=GetVersion();
|
||||
if(set_schema==0) {
|
||||
printf("%d\n",start_schema);
|
||||
exit(0);
|
||||
}
|
||||
if((set_schema<RDREVERT_BASE_SCHEMA)||(set_schema>start_schema)) {
|
||||
fprintf(stderr,"rdrevert: unsupported schema\n");
|
||||
exit(256);
|
||||
}
|
||||
|
||||
while(start_schema>set_schema) {
|
||||
Revert(start_schema--);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert(int schema) const
|
||||
{
|
||||
switch(schema) {
|
||||
case 243:
|
||||
Revert243();
|
||||
break;
|
||||
|
||||
case 244:
|
||||
Revert244();
|
||||
break;
|
||||
|
||||
case 245:
|
||||
Revert245();
|
||||
break;
|
||||
|
||||
case 246:
|
||||
Revert246();
|
||||
break;
|
||||
|
||||
case 247:
|
||||
Revert247();
|
||||
break;
|
||||
|
||||
case 248:
|
||||
Revert248();
|
||||
break;
|
||||
|
||||
case 249:
|
||||
Revert249();
|
||||
break;
|
||||
|
||||
case 250:
|
||||
Revert250();
|
||||
break;
|
||||
|
||||
case 251:
|
||||
Revert251();
|
||||
break;
|
||||
|
||||
case 252:
|
||||
Revert252();
|
||||
break;
|
||||
|
||||
case 253:
|
||||
Revert253();
|
||||
break;
|
||||
|
||||
case 254:
|
||||
Revert254();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert243() const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
|
||||
sql=QString("alter table STATIONS drop column HAVE_MP4_DECODE");
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
SetVersion(242);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert244() const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
|
||||
sql=QString("alter table JACK_CLIENTS modify column COMMAND_LINE ")+
|
||||
"char(255) not null";
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
SetVersion(243);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert245() const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
|
||||
sql=QString("alter table RDLIBRARY drop column READ_ISRC");
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
SetVersion(244);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert246() const
|
||||
{
|
||||
SetVersion(245);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert247() const
|
||||
{
|
||||
SetVersion(246);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert248() const
|
||||
{
|
||||
SetVersion(247);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert249() const
|
||||
{
|
||||
SetVersion(248);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert250() const
|
||||
{
|
||||
SetVersion(249);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert251() const
|
||||
{
|
||||
SetVersion(250);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert252() const
|
||||
{
|
||||
SetVersion(251);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert253() const
|
||||
{
|
||||
SetVersion(252);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Revert254() const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
|
||||
sql=QString("alter table CUTS drop column PLAY_ORDER");
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
sql=QString("alter table CART drop column USE_WEIGHTING");
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
SetVersion(253);
|
||||
}
|
||||
|
||||
|
||||
int MainObject::GetVersion() const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
int ret=0;
|
||||
|
||||
sql=QString("select DB from VERSION");
|
||||
q=new QSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
ret=q->value(0).toInt();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::SetVersion(int schema) const
|
||||
{
|
||||
QString sql;
|
||||
QSqlQuery *q;
|
||||
|
||||
sql=QString().sprintf("update VERSION set DB=%d",schema);
|
||||
q=new QSqlQuery(sql);
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
int MainObject::MapSchema(const QString &ver)
|
||||
{
|
||||
QString version=ver;
|
||||
bool ok=false;
|
||||
|
||||
//
|
||||
// Version -> Schema Map
|
||||
//
|
||||
std::map<QString,int> version_map;
|
||||
version_map["2.10"]=242;
|
||||
version_map["2.11"]=245;
|
||||
version_map["2.12"]=254;
|
||||
|
||||
//
|
||||
// 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(version_map.count(f0[0]+"."+f0[1])==0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return version_map[f0[0]+"."+f0[1]];
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
new MainObject(NULL,"main");
|
||||
return a.exec();
|
||||
}
|
61
utils/rdrevert/rdrevert.h
Normal file
61
utils/rdrevert/rdrevert.h
Normal file
@ -0,0 +1,61 @@
|
||||
// rdrevert.h
|
||||
//
|
||||
// Revert the Rivendell database schema to an earlier version.
|
||||
//
|
||||
// (C) Copyright 2016 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.
|
||||
//
|
||||
|
||||
#ifndef RDREVERT_H
|
||||
#define RDREVERT_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rddb.h>
|
||||
|
||||
#define RDREVERT_BASE_SCHEMA 242
|
||||
#define RDREVERT_USAGE "[options]\n"
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
public:
|
||||
MainObject(QObject *parent=0,const char *name=0);
|
||||
|
||||
private:
|
||||
void Revert(int schema) const;
|
||||
void Revert243() const;
|
||||
void Revert244() const;
|
||||
void Revert245() const;
|
||||
void Revert246() const;
|
||||
void Revert247() const;
|
||||
void Revert248() const;
|
||||
void Revert249() const;
|
||||
void Revert250() const;
|
||||
void Revert251() const;
|
||||
void Revert252() const;
|
||||
void Revert253() const;
|
||||
void Revert254() const;
|
||||
int GetVersion() const;
|
||||
void SetVersion(int schema) const;
|
||||
int MapSchema(const QString &ver);
|
||||
RDConfig *rev_config;
|
||||
QSqlDatabase *rev_db;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDREVERT_H
|
Loading…
x
Reference in New Issue
Block a user