[odb-users] Schema creation for a scattered database
Javier Gutierrez
javier.gutierrez at web.de
Wed Jan 14 07:06:50 EST 2026
Hello Boris,
I wish a happy new year to you and all.
I am wondering how to use the ODB feature
odb::schema_catalog::create_schema() for a database that is scattered among
different parts of the application.
My application has different libraries. Each library has its own set of
tables. All tables have foreign keys pointing to the main tables (main
application). These libraries may or may not be installed on the target
system. Therefore, their corresponding tables also may or may not be created
at the target database. Or they may be installed later.
My idea was for each library to generate a separate schema
(--generate-schema-only --generate-format separate) with all its tables, and
then to run create_schema() on the target system for each of the libraries.
But each of generated schemas will also contain the DROP and CREATE
statement for the main tables.
My question is, what is the best way to deal with such a scenario? I guess a
second call to create_schema() will try to DROP and CREATE the main tables
deleting any already available data or failing because of foreign key
constraint? Or maybe create_schema() will not even run more than once
because it will tell me the schema is already created?
I know the best would be if each library's tables are created within an
independent model, but as per the documentation, no headers from one model
shall include a header from another one. Which unfortunately is not my case.
I also wanted to profit from the schema evolution feature, but I am not sure
of the above.
Thanks in advance and best regards.
More information about the odb-users
mailing list