Replies: 1 comment 2 replies
-
Beyond "it works", I am not really all that invested in how the database code works now. rocketman did an impressive job in the initial transition from beerXML to rdbms. I've made pretty much a hash of it since. After pulling the XML code out of database.cpp, I had thought the split you mention would be the next most logical. The meta of starting, opening, etc. shouldn't be intermixed with "write this field to the database". I am, in other words, very interested. I just hope I can understand what you've done. If what you did in the XML code is any indication, it will take me a lot of work to figure out how it works. A few things to suggest. I know the DatabaseSchema may not be the best way to do it but your solution has to address the base problem. Simply expressed, we need some fairly generic way to handle the same object field having different names in the database. Backporting the versions will be a good test, as it requires adding a new column. Try adding a new table and see how easy that is or isn't. If I had to make a choice, I would rather it be easier to add a column than a table. I would also like to keep the number of edits required to add a new column to a bare minimum. Again, TableSchema isn't the greatest but it really did make it easier. Any changes to the database layer should make sure that upgrading still works (pull a database from 2.3.1 and see what happens). I would also be happy if it didn't break the postgresql support, or being able to move between them. Since I am likely the only one who cares about that, I will do the tests and and PR to fix it. |
Beta Was this translation helpful? Give feedback.
-
I'm coming towards the end (I think!) of reworking the database layer. I've been doing the work in Brewken, and I want to know whether there is appetite (when it's finished) to backport it to Brewtarget (which I'd be happy to do). It is quite a big change, but I think it will make life easier for future DB schema changes (and I think now BeerJSON is released, there might be a fair few of those to come as it introduces a bunch of things not present in BeerXML 1.0).
The basic idea of my reworking is to move from DB-centric to object-centric code. I've pulled a lot of the model/business "logic" (eg how do we add something to a Recipe or change the order of MashSteps) up into the model classes (rather than having special functions on Database class to handle it). I've also separated out the "how do I connect to a database / do backups / etc" (which stays in database/Database.cpp) from "how do I map classes and their fields to database tables and their fields" (mostly in database/ObjectStoreTyped.cpp and database/ObjectStore.cpp). I think it makes the code smaller and easier to extend. (I'll get to test this soon when I port @mikfire's recipe versioning to Brewken.)
Anyway, wanted to get folks' thoughts...
Beta Was this translation helpful? Give feedback.
All reactions