a
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
// UpdateDataBase.h: interface for the CUpdateDataBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "Markup.h"
|
||||
|
||||
#if !defined(AFX_UPDATEDATABASE_H__65574C8D_6ABD_4A5C_8943_C38142D7BDD5__INCLUDED_)
|
||||
#define AFX_UPDATEDATABASE_H__65574C8D_6ABD_4A5C_8943_C38142D7BDD5__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
typedef struct STCOLUMNINFO
|
||||
{
|
||||
CString strColName;//列名
|
||||
CString strRefTableName;//外键约束的表名
|
||||
CString strRefTableCol;//外键约束的字段名
|
||||
int nModifyType; //操作的类型,0:不更改, 1: 增加 2:删除 3:修改,主键的属性是不能进行修改的
|
||||
int nValueType; //从1开始
|
||||
int nAttrType;
|
||||
int nIsPrimaryKey;
|
||||
int nIsForeignKey;
|
||||
int nIndex;
|
||||
int nIsEmpty;
|
||||
int nIsCompress;
|
||||
STCOLUMNINFO()
|
||||
{
|
||||
strColName = _T("");
|
||||
strRefTableName = _T("");
|
||||
strRefTableCol = _T("");
|
||||
nModifyType = 0;
|
||||
nValueType = 1;
|
||||
nAttrType = 50;
|
||||
nIsPrimaryKey = 0;
|
||||
nIsForeignKey = 0;
|
||||
nIndex = 0;
|
||||
nIsEmpty = 0;
|
||||
nIsCompress = 0;
|
||||
}
|
||||
}STColInfo;
|
||||
|
||||
typedef struct STTABLEINFO
|
||||
{
|
||||
CString strTableName;
|
||||
int nModifyType; //操作的类型,0:不更改, 1: 增加 2:删除 3:修改
|
||||
std::vector<STColInfo> vtColInfo;
|
||||
STTABLEINFO()
|
||||
{
|
||||
strTableName = _T("");
|
||||
nModifyType = 0;
|
||||
vtColInfo.clear();
|
||||
}
|
||||
|
||||
}STTableInfo;
|
||||
|
||||
typedef enum EN_UPDATEDB_RES
|
||||
{
|
||||
enResFail = 0,
|
||||
enResSuccess,
|
||||
enResNoUpdate
|
||||
}EnUpdateDBRes;
|
||||
|
||||
static char* chValueType[20] = {"varchar", "text", "tinyint", "smallint", "integer", "real",
|
||||
"float", "money", "counter", "datetime", "bit", "image"};
|
||||
|
||||
|
||||
class CUpdateDataBase
|
||||
{
|
||||
public:
|
||||
CUpdateDataBase(_ConnectionPtr pConnection, CString strVer);
|
||||
virtual ~CUpdateDataBase();
|
||||
bool ParserUpdateDBXml();
|
||||
int UpdateDBInfo();
|
||||
|
||||
|
||||
protected:
|
||||
//functions
|
||||
bool QueryPreVersion();
|
||||
|
||||
bool WriteVersionToDB();
|
||||
|
||||
void PrintLog(CString& strLog);
|
||||
|
||||
bool GetDBUpdatesInfo(); //解析数据库的更新新,前提是必须先跳转到pre_version元素中
|
||||
|
||||
STColInfo GetColumnInfo(int nType);
|
||||
|
||||
|
||||
bool AddDBTable(STTableInfo pstTable);
|
||||
|
||||
bool DeleteDBTable(STTableInfo stTable);
|
||||
|
||||
bool ModifyDBTable(STTableInfo stTable);
|
||||
|
||||
bool AddTableCol(CString strTable, STColInfo stCol, std::vector<CString>& vtSql);
|
||||
|
||||
bool ModifyTableCol(CString strTable, STColInfo stCol, std::vector<CString>& vtSql);
|
||||
|
||||
bool CheckNecessaryVersion();//为了填补1.5版本中versioninfo表中没有字段的问题而引入的临时解决方案
|
||||
|
||||
//member
|
||||
STTableInfo m_stDBModifyInfo;
|
||||
std::vector<STTableInfo> m_vtUpdateDBInfo;
|
||||
CMarkup m_opXml;
|
||||
FILE* m_pLog;
|
||||
CString m_strPreVersion;
|
||||
_ConnectionPtr m_pConnection;
|
||||
CString m_strCurVer;
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_UPDATEDATABASE_H__65574C8D_6ABD_4A5C_8943_C38142D7BDD5__INCLUDED_)
|
||||
Reference in New Issue
Block a user