Venerable Monks!

In the near future I will have to face the problem of persisting Moose-based objects in a relational database which of course is not a problem as such.

Now presumably there will be an evolution as far as the objects/classes are concerned as new requirements need to be addressed or the code gets refactored - or put more simply: Some attributes could get added, other may get removed.

What I want to achive now is a way to decouple the evolution of the class-level from the database-level, i.e. I want to have a way to change (some) aspects of the class without having to change the database-schema (which from my experience gets messy once an application is in production).

So what I am thinking about is this:

All our classes will be based on Moose, i.e. they can be easily (and also generically) serialized as either XML or YAML.
So why not have one set of attributes that simply get mapped to database-fields of their own and at the same time have another set of attributes that get serialized as XML or YAML and that get then stored in a common CLOB field.

In this way I could change the latter set of attributes without affecting the database-schema.

The way I would implement it is via a class-trait that would allow individual attributes to be tagged as either belonging to the first or second group.

If the above is understandable at all: Does that make sense to you or would it be just a bad idea (if so why?).

This is just a vague idea I had (and by now I probably had one beer too many) so I am sorry if it just sounds like gibberish to you.

Many thanks anyway!


In reply to persisting Moose objects and schema evolution by morgon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.