[odb-users] Schema Migration not working correctly

Tschoche.Jonas at ddv-mediengruppe.de Tschoche.Jonas at ddv-mediengruppe.de
Tue Jun 16 07:17:20 EDT 2020


Hello,

Sorry for the late response.

Also I know that the odb compiler use and maintain the changelog, but when I delete database and the changelog and compile the project first time, no entries are added. When I edit the table schema (adding a new field in C++ Object Model) then a add-table entry appairs in odb changelog – I think on first build it should have all table definitions and when I adding a field then should it make a alter-table in changelog.

I build each with following options:

Example for one file:
cd PROJDIR && /usr/local/bin/odb -d mysql --generate-query --generate-schema --schema-format separate --std c++17 --include-regex "%(.*)/(.+)%\$2%" --fkeys-deferrable-mode not_deferrable --profile boost/date-time --profile boost/optional --profile boost/uuid --changelog odb-changelog.log --changelog-dir PROJDIR --default-pointer std::shared_ptr --output-dir PROJDIR/cmake-build-debug/odb_gen --hxx-suffix .hpp --ixx-suffix _inline.hpp --cxx-suffix .cpp --odb-file-suffix _odb -I/usr/local/include -I/usr/local/include

I tested it many times remove all I added a new field for a table and the table is dedected, but I don’t like to write the initial xml file by hand to make this working.

I don’t see the issue.

Step by Step:


  1.  I cleaned the database and schmea_versions table.
  2.  Reset CMake Cache
  3.  Delete odb_changelog
  4.  Complete recompile
  5.  Look in odb_changelog -> Result: no entries
  6.  Make a change in a c++ object model
  7.  Set new versionsnumber (I use a base class for all tables – see bottom) 1, 1 -> 1, 2
  8.  Recompile
  9.  Entry for Table definition is added
  10. Run Programm -> Crash on Schema migration, because table exist.

BaseClass:
#pragma db model version(1, 1)
#pragma db object abstract
class BaseEntity {}

Object:

#pragma db object table("TABLE")
class TABLE : public BaseEntity {}



Von: Paul Stath <PStath at jmawireless.com>
Datum: Donnerstag, 30. April 2020 um 18:40
An: "odb-users at codesynthesis.com" <odb-users at codesynthesis.com>, "Tschoche, Jonas" <Tschoche.Jonas at ddv-mediengruppe.de>
Cc: Boris Kolpackov <boris at codesynthesis.com>
Betreff: RE: [odb-users] Schema Migration not working correctly

This message has been archived.  View the original item <http://Ddv-vault.int.dd-v.de/EnterpriseVault/Search/htmlview.aspx?VaultId=187B10FE5AD49A342A5F0ADDF8AC5DED81110000ddv-vault&SavesetId=202005280685156~202004301640540000~Z~B074F9FD680402AD3353E25CD37D1C11>
As Boris responded, a small example will go a long way towards allowing others to help.

I had a similar experience when I first started using schema migration in my project, maybe you are having the same issue?

In the "C++ Object Persistence with ODB" manual in the "Object Model Version and Changelog" section (https://www.codesynthesis.com/products/odb/doc/manual.xhtml#13.1) is a very important paragraph.  (capitalization added for emphasis)

       "The changelog is maintained by the ODB compiler. Specifically, you do not need to make any manual changes to this file.
        You will, however, need to KEEP IT AROUND from one invocation of the ODB compiler to the next. In other words, the changelog
        file is BOTH the INPUT and the OUTPUT of the ODB compiler. This, for example, means that if your project's source code is stored
        in a version control repository, then you will most likely want to store the changelog there as well. If you delete the changelog,





More information about the odb-users mailing list