[odb-users] Cannot create schema

Michał Snoch kontakt at msnoch.pl
Wed Oct 26 14:39:29 EDT 2011


Hi

I have weird issue. Everything worked fine until now. I have 3 model 
structs,


departure.h:

    #include <odb/core.hxx>
    #include <QTime>

    namespace Core
    {

    namespace Model
    {

    enum DepartureType{
         Normal, Saturday, FreeDay
    };

    #pragma db object
    struct Departure
    {
         friend class odb::access;

         #pragma db id auto
         unsigned int id;

         QTime arrival;
         DepartureType type;
    };

    } // namespace Model

    } // namespace Core

connection.h

    #include <boost/shared_ptr.hpp>
    #include "node.h"
    #include "departure.h"

    #include <odb/core.hxx>
    #include <QString>
    #include <QVector>

    namespace Core
    {

    namespace Model
    {

    typedef int Weight;

    #pragma db object
    struct Connection
    {
         friend class odb::access;

    #pragma db id auto
         unsigned int id;
         boost::shared_ptr<Node> start;
         boost::shared_ptr<Node> stop;
         Weight weight;
         QString name;
         short variation;

         QVector<boost::shared_ptr<Departure> > departures;
    };

    } // namespace Model

    } // namespace Core

and node.h:

    #include <odb/core.hxx>
    #include <QString>

    namespace Core
    {

    namespace Model
    {

    typedef unsigned int NodeId;

    #pragma db object
    struct Node
    {
         friend class odb::access;

         Node() : lat(0.0f), lon(0.0f), id(0) {}

         #pragma db id auto
         NodeId id;

         QString m_street, m_name;

         float lat;
         float lon;
    };

    } // namespace Model

    } // namespace Core

and when I'm trying to create schema via

    transaction t1(db->begin());
    odb::schema_catalog::create_schema (*db);
      t1.commit();

I'm getting error that Node already exists

    42P07: ERROR: relation "Node" already exists


When I'm generating sql files and executing them
by myself everything is ok. Of course there is no
Node table in db when I'm doing that.

What should I do?
Thanks
Michal






More information about the odb-users mailing list