So I am trying to do something interesting with my classes.

I am trying to implement history in the database.
To keep the ORM simple, they way I am approaching it is to have two
objects (Host vs HostRevision)  and two tables (host vs host_revision)
that are connected by triggers.

Any changes made to 'host' (insert/update/delete), are copied (insert)
into the 'host_revision', with a version number.  Then there is a Host
object and a HostRevision table.  They have all the same columns,
except the later has a version number in it to distinguish the
different revisions.

So far the code looks like this:


class Host(Entity):
    using_options(tablename="host")
    name = Field(String(40))
    hardware = Field(String(40))

class HostRevision(Entity):
    using_options(tablename="host")
    name = Field(String(40))
    hardware = Field(String(40))
    revision_number = Field(Integer)


The only difference between the two is that the second one has an
extra field.
Basically whenever I add a field to the first one, the second one
needs to have the field two.

Ideally I could look at the first one and build the second one.  This
includes copying the columns, and foreign keys over in such a way as
to make them unique.

I assumed that I could look at the entity descriptor for the first and
build the second.  Is this possible?  Could I have some guidance at
when to do that and what data to pull from where?

n


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to