MidgardStorage

MidgardStorage — Underlying storage creator

Synopsis

#include <midgard/midgard.h>

                    MidgardStorage;
                    MidgardStorageClass;
gboolean            midgard_storage_create_base_storage (MidgardConnection *mgd);
gboolean            midgard_storage_create              (MidgardConnection *mgd,
                                                         const gchar *name);
gboolean            midgard_storage_update              (MidgardConnection *mgd,
                                                         const gchar *name);
gboolean            midgard_storage_exists              (MidgardConnection *mgd,
                                                         const gchar *name);
gboolean            midgard_storage_delete              (MidgardConnection *mgd,
                                                         const gchar *name);

Object Hierarchy

  GObject
   +----MidgardStorage

Description

MidgardStorage is reponsible for creating underlying storage. It creates storage for every MidgardDBObjectClass derived one. For example, normal database tables are created for MidgardObjectClass derived classes, and database views for MidgardViewClass derived ones.

It is very important to understand that MidgardStorage doesn't have specific implementation which creates storage tables. Instead, it invokes private routines of MidgardDBObjectClass derived classes.

Details

MidgardStorage

typedef struct _MidgardStorage MidgardStorage;

Since 9.09


MidgardStorageClass

typedef struct _MidgardStorageClass MidgardStorageClass;

Since 9.09


midgard_storage_create_base_storage ()

gboolean            midgard_storage_create_base_storage (MidgardConnection *mgd);

Creates storage for base Midgard classes. Tables created by this method: repligard, midgard_user and midgard_person.

mgd :

MidgardConnection instance

Returns :

TRUE if tables has been created, FALSE otherwise.

Since 9.09


midgard_storage_create ()

gboolean            midgard_storage_create              (MidgardConnection *mgd,
                                                         const gchar *name);

Creates underlying storage (e.g. table in database) for class which is identified by given name. It may be class which represents any underlying storage type (database table or view, for example).

If underlying storage already exists, this method silently ignore creation and returns TRUE. Such case is not considered an error.

This method also creates metadata storage if given class uses such.

Indexes are created if:

  • property is a link type

  • property is linked to another property

  • property is either parent or up

  • property holds guid value

Auto increment (and primary key ) field is created if property is defined as primaryproperty, and it's integer ( or unsigned one ) type

mgd :

MidgardConnection instance

name :

name of MidgardDBObject derived class

Returns :

TRUE on success, FALSE otherwise

Since 10.05


midgard_storage_update ()

gboolean            midgard_storage_update              (MidgardConnection *mgd,
                                                         const gchar *name);

Update underlying storage.

This method doesn't create storage. It creates new columns if are defined for class properties and do not exist in storage yet.

See midgard_storage_create() if you need more info about indexes.

mgd :

MidgardConnection instance

name :

Name of MidgardDBObjectClass derived class.

Returns :

TRUE on success, FALSE otherwise

Since 10.05


midgard_storage_exists ()

gboolean            midgard_storage_exists              (MidgardConnection *mgd,
                                                         const gchar *name);

Checks whether storage for given class exists.

mgd :

MidgardConnection instance

name :

Name of MidgardDBObjectClass derived class

Returns :

TRUE if storage exists, FALSE otherwise

Since 10.05


midgard_storage_delete ()

gboolean            midgard_storage_delete              (MidgardConnection *mgd,
                                                         const gchar *name);

Delete storage for given class.

mgd :

MidgardConnection instance

name :

name of MidgardDBObjectClass derived class.

Returns :

TRUE on success, FALSE otherwise

Since 10.05