From javier.gutierrez at web.de Wed Jan 14 07:06:50 2026 From: javier.gutierrez at web.de (Javier Gutierrez) Date: Wed Jan 14 07:07:10 2026 Subject: [odb-users] Schema creation for a scattered database In-Reply-To: <033701dc854d$c82eab70$588c0250$@web.de> References: <033701dc854d$c82eab70$588c0250$@web.de> Message-ID: <033901dc854e$4424adb0$cc6e0910$@web.de> 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. From boris at codesynthesis.com Thu Jan 15 08:19:38 2026 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 15 08:19:50 2026 Subject: [odb-users] Schema creation for a scattered database In-Reply-To: <033901dc854e$4424adb0$cc6e0910$@web.de> References: <033701dc854d$c82eab70$588c0250$@web.de> <033901dc854e$4424adb0$cc6e0910$@web.de> Message-ID: Javier Gutierrez writes: > 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. This feature expects each named schema to be self-contained. > My question is, what is the best way to deal with such a scenario? The only option that I can think of is to manage the foreign keys yourself. Without the foreign keys pointing to the main table your schemas are self-contained. So you could create them and then add the necessary foreign keys manually.