[odb-users] How to retrieve schema name ?

David Sarrut David.Sarrut at creatis.insa-lyon.fr
Fri Mar 20 08:47:40 EDT 2015


even simpler, thanks !

David

On Thu, Mar 19, 2015 at 3:11 PM, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Hi David,
>
> Yes, Per got it right, the easiest way to get this information is
> to use a view. Section 13.2, "Schema Migration" has the description
> of this table:
>
> "... By default, when schema evolution is enabled, ODB maintains this
>  information in a special table called schema_version that has the
>  following (or equivalent, depending on the database used) definition:"
>
>
> CREATE TABLE "schema_version" (
>   "name" TEXT NOT NULL PRIMARY KEY,
>   "version" BIGINT NOT NULL,
>   "migration" BOOLEAN NOT NULL);
>
>
> "The name column is the schema name as specified with the --schema-name
>  option. It is empty for the default schema. The version column contains
> the
>  current database version. And, finally, the migration flag indicates
> whether
>  we are in the process of migrating the database, that is, between the pre
> and
>  post-migration stages."
>
> One improvement on Per's suggestion would be to use a table view rather
> than a native view. A bit less raw SQL:
>
> #pragma db view table("schema_version")
> struct schema_name
> {
>   #pragma db column("name")
>   std::string name;
> };
>
> Boris
>



-- 
David Sarrut, Phd
Directeur de recherche CNRS
CREATIS, UMR CNRS 5220, Inserm U 1044
Centre de lutte contre le cancer Léon Bérard
28 rue Laënnec, 69373 Lyon cedex 08
Tel : 04 78 78 51 51 / 06 74 72 05 42
http://www.creatis.insa-lyon.fr/~dsarrut
_________________________________
 "2 + 2 = 5,  for extremely large values of 2"
_________________________________


More information about the odb-users mailing list