[odb-users] error: SQLite does not support altering of columns.
info: first altered column is 'password' in table 'user',
but field password is not being altered
Rafal Gm
grasmanek94 at gmail.com
Sun Oct 26 12:52:19 EDT 2014
Hello, I am trying to use the database migration features of ODB on which I
have been waiting a long time, but for some reason it gives alter errors
after adding one more integer column to the database.
This is my version 1_1 class:
#include <string>
#include <odb/core.hxx>
#define acmf(variable_type,variable_name) \
public:\
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
} \
void variable_name (variable_type variable_name) \
{ \
variable_name ## _ = variable_name; \
}\
private:\
variable_type variable_name ## _
#define accessor(variable_name,variable_type) \
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
}
#define ResetValue(name) name ## _(0)
#define ResetValueStr(name) name ## _("")
#pragma db model version(1, 1)
#pragma db object
class user
{
public:
user () {}
user
(
std::string nickname,
std::string password
):
nickname_(nickname),
password_(password),
ResetValue(money),
ResetValue(score),
ResetValue(kills),
ResetValue(experience),
ResetValue(deaths),
ResetValue(privilidges),
ResetValue(bounty),
ResetValue(suicides),
ResetValue(respect),
ResetValue(kicks),
ResetValue(warns),
ResetValue(playtime),
ResetValue(banned),
ResetValueStr(ban_reason),
ResetValueStr(ban_who)
{}
accessor(nickname, std::string);
acmf(std::string, password);
acmf(signed long long,money);
acmf(signed long long,score);
acmf(unsigned long long,kills);
acmf(unsigned long long,experience);
acmf(unsigned long long,deaths);
acmf(unsigned long long,privilidges);
acmf(unsigned long long,bounty);
acmf(unsigned long long,suicides);
acmf(unsigned long long,respect);
acmf(unsigned long long,kicks);
acmf(unsigned long long,warns);
acmf(unsigned long long,playtime);
acmf(unsigned long long,banned);
acmf(std::string,ban_reason);
acmf(std::string,ban_who);
private:
friend class odb::access;
#pragma db unique id index
std::string nickname_;
};
and this is the next version:
#include <string>
#include <odb/core.hxx>
#define acmf(variable_type,variable_name) \
public:\
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
} \
void variable_name (variable_type variable_name) \
{ \
variable_name ## _ = variable_name; \
}\
private:\
variable_type variable_name ## _
#define accessor(variable_name,variable_type) \
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
}
#define ResetValue(name) name ## _(0)
#define ResetValueStr(name) name ## _("")
#pragma db model version(1, 2)
#pragma db object
class user
{
public:
user() {}
user
(
std::string nickname,
std::string password
) :
nickname_(nickname),
password_(password),
ResetValue(money),
ResetValue(score),//unused
ResetValue(kills),
ResetValue(experience),
ResetValue(deaths),
ResetValue(privilidges),
ResetValue(bounty),
ResetValue(suicides),
ResetValue(respect),
ResetValue(kicks),
ResetValue(warns),
ResetValue(playtime),
ResetValue(banned),
ResetValueStr(ban_reason),
ResetValueStr(ban_who),
ResetValue(jailtime)
{}
accessor(nickname, std::string);
acmf(std::string, password);
acmf(long long, money);
acmf(long long, score);//unused
acmf(unsigned long long, kills);
acmf(unsigned long long, experience);
acmf(unsigned long long, deaths);
acmf(unsigned long long, privilidges);
acmf(unsigned long long, bounty);
acmf(unsigned long long, suicides);
acmf(long long, respect);
acmf(unsigned long long, kicks);
acmf(unsigned long long, warns);
acmf(unsigned long long, playtime);
acmf(unsigned long long, banned);
acmf(std::string, ban_reason);
acmf(std::string, ban_who);
acmf(unsigned long long, jailtime);
private:
friend class odb::access;
#pragma db unique id index
std::string nickname_;
};
as you can see I have 'only added unsigned long long jailtime'.
When I throw the file onto the ODB compiler with the following command:
tools\bin\odb.exe -d sqlite %filename%
I get the following errors:
error: SQLite does not support altering of columns
info: first altered column is 'password' in table 'user'
How can I fix this?
Thanks in advance! :)
More information about the odb-users
mailing list