[Dbix-class] Schema::Loader and views on Pg
Dorian Taylor (Lists)
dorian.taylor.lists at gmail.com
Sat May 1 19:53:28 GMT 2010
Hey guys, been a while...
I have a Postgres (current) database that has a bunch of log tables.
On top of those is a bunch of views that take the most recent record,
basically going like:
CREATE VIEW foo AS SELECT * FROM foo_log a
WHERE NOT EXISTS (SELECT 1 from foo_log b where b.since > a.since);
("Since" is a timestamp and part of the primary key in the log table,
but not in the view, of course.)
Anyhow, I'm trying to use Schema::Loader (current) to build out the
schema and it (naturally) sees these views as not having primary keys
and the columns as nullable (they aren't in the underlying tables) and
of course no relationships, though the underlying log tables are
related to one another. I don't expect Schema::Loader can see that, I
just want to override it.
So what I'm wondering is if there is a way to tell Schema::Loader
"these views are just like those tables minus one dimension" or if I'm
better off just concocting the classes for those views by hand.
Oh, one other thing. I could have sworn a few years ago that I could
abridge the class names in relation specs, just putting Foo instead of
My::Schema::Foo in has_many/belongs_to etc. Did that change?
More information about the DBIx-Class