[Dbix-class] Avoiding foreign key constraint on a relationship
W Snyder
wsnyder at wsnyder.org
Sun Mar 1 16:37:36 GMT 2009
One of my DBIx::Class table classes has:
__PACKAGE__->table("adjacents");
__PACKAGE__->add_columns(
"child_id" => { ... },
"parent_id" => { ... },
);
__PACKAGE__->set_primary_key("child_id");
__PACKAGE__->base_has_one(parent_string => 'X::Schema::String',
{'foreign.object_id' => 'self.parent_id'});
This results in the (MySQL) creation commands
CREATE TABLE `adjacents` (
...
CONSTRAINT `fk_parent_id` FOREIGN KEY (`parent_id`)
REFERENCES `strings` (`object_id`)
The problem is I want to eliminate this constraint from the
SQL creation but not from what DBIx accessors are made.
(Because the constraint is sometimes violated, and I need to
index it in a special way).
How do I create a relationship so I can call
$object->parent_string, but not have a CONSTRAINT added to
the database schema?
Thanks
More information about the DBIx-Class
mailing list