[Catalyst] Problems with relation in DBIx::Class::Schema::Loader

cylontoaster cylontoaster at gmx.de
Mon Apr 16 14:24:25 GMT 2012


Hello,
when I wanted to move my code to a production-machine I got a new 
warning, which I don't really understand & a new realtionship-name .
On both machines exists the similar MySQL-DB with real foreign keys.
For creating the Schema I always used  DBIx::Class::Schema::Loader, 
which also created the right relations .. it always worked fine.

Now on the new machine I get this warning, but only with one table even 
if there are more or less similar ones, with the same structure:

Could not find a proper name for relationship 'groupusers_2s' in source
'User' for columns 'user_id'. Supply a value in
'inflect_plural' for 'groupusers_2' or 'rel_name_map' for
'groupusers_2s' to name this relationship.
Could not find a proper name for relationship 'users_2s' in source
'Groupuser' for columns 'groupuser_id'. Supply a value in
'inflect_plural' for 'users_2' or 'rel_name_map' for
'users_2s' to name this relationship.
Dumping manual schema for DW::Schema to directory 
/home/datweb/DW/script/../lib ...
Schema dump completed.
DBIx::Class::Carp::__ANON__():
***************************************************************************
The many-to-many relationship 'users' is trying to create a utility method
called add_to_users.
This will completely overwrite one such already existing method on class
DW::Schema::Result::Role.

You almost certainly want to rename your method or the many-to-many
relationship, as the functionality of the original method will not be
accessible anymore.

To disable this warning set to a true value the environment variable
DBIC_OVERWRITE_HELPER_METHODS_OK
...




env DBIC_OVERWRITE_HELPER_METHODS_OK=1 doesn't help :-(

Having a look inside User.pm you can also see, that the Schema-Loader 
also created a new relationship-name with a _2s-ending:

__PACKAGE__->many_to_many("groupusers", "user_groupusers", "groupuser");
=head2 groupusers_2s
Type: many_to_many
Composing rels: L</groupuser_users> -> groupuser
=cut
__PACKAGE__->many_to_many("groupusers_2s", "groupuser_users", "groupuser");





These are the versions I use:

Testing:
+ DBIx::Class::Schema::Loader: 0.07009
+ Catalyst::Runtime 5.80032

Production:
+ DBIx::Class::Schema::Loader: 0.07022
+ Catalyst::Runtime 5.90011


This is the SQL-Code:


--
-- Table structure for table `groupuser_user`
--

CREATE TABLE IF NOT EXISTS `groupuser_user` (
   `groupuser_id` int(10) NOT NULL COMMENT 'PK',
   `user_id` int(10) NOT NULL COMMENT 'PK',
   PRIMARY KEY  (`groupuser_id`,`user_id`),
   KEY `groupuser_id` (`groupuser_id`),
   KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='User_users';


--
-- Constraints for table `groupuser_user`
--
ALTER TABLE `groupuser_user`
   ADD CONSTRAINT `groupuser_user_ibfk_1` FOREIGN KEY (`groupuser_id`) 
REFERENCES `groupuser` (`groupuser_id`),
   ADD CONSTRAINT `groupuser_user_ibfk_2` FOREIGN KEY (`user_id`) 
REFERENCES `user` (`user_id`);




--
-- Table structure for table `groupuser`
--

CREATE TABLE IF NOT EXISTS `groupuser` (
   `groupuser_id` int(10) NOT NULL auto_increment COMMENT 'PK',
   `groupuser_name` varchar(64) collate utf8_unicode_ci NOT NULL COMMENT 
'Name of the Project (SIM)',
   `groupuser_status` enum('active','deactivated','deleted') collate 
utf8_unicode_ci NOT NULL default 'active',
   `groupuser_comment` text collate utf8_unicode_ci COMMENT 'description 
of the group',
   PRIMARY KEY  (`groupuser_id`),
   UNIQUE KEY `groupuser_name` (`groupuser_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 
COMMENT='groupusers' AUTO_INCREMENT=1 ;



--
-- Table structure for table `user`
--

CREATE TABLE IF NOT EXISTS `user` (
   `user_id` int(10) NOT NULL auto_increment COMMENT 'PK',
   `project_id` int(10) default NULL COMMENT 'FK project',
   `user_name` varchar(64) collate utf8_unicode_ci NOT NULL COMMENT 
'identification',
   `user_givenName` varchar(128) collate utf8_unicode_ci default NULL,
   `user_sn` varchar(128) collate utf8_unicode_ci default NULL,
   `user_pwd` varchar(64) collate utf8_unicode_ci default NULL COMMENT 
'password',
   `user_email` varchar(128) collate utf8_unicode_ci default NULL 
COMMENT 'Email',
   `user_telephone` varchar(128) collate utf8_unicode_ci default NULL 
COMMENT 'Telephone',
   `user_lang` varchar(2) collate utf8_unicode_ci NOT NULL default 'de' 
COMMENT 'selected language',
   `user_loginDisabled` enum('true','false') collate utf8_unicode_ci NOT 
NULL default 'false' COMMENT 'attribute of SimAUTH, if login is possible',
   `user_status` enum('active','deactivated','deleted') collate 
utf8_unicode_ci NOT NULL default 'active' COMMENT 'attribute of SimAUTH 
- mwnAuthUserStatus',
   `user_type` enum('LDAP','DB') collate utf8_unicode_ci NOT NULL 
default 'DB' COMMENT 'local(DB) / public(LDAP)',
   `user_comment` text collate utf8_unicode_ci,
   PRIMARY KEY  (`user_id`),
   UNIQUE KEY `user_name` (`user_name`),
   KEY `project_id` (`project_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 
COMMENT='users' AUTO_INCREMENT=5 ;


--
-- Constraints for table `user`
--
ALTER TABLE `user`
   ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES 
`project` (`project_id`);





I have more or less the same code for the another table. Here I don't 
get any complaints:


--
-- Table structure for table `groupnode_node`
--

CREATE TABLE IF NOT EXISTS `groupnode_node` (
   `groupnode_id` int(10) NOT NULL COMMENT 'PK',
   `node_id` int(10) NOT NULL COMMENT 'PK',
   PRIMARY KEY  (`groupnode_id`,`node_id`),
   KEY `groupnode_id` (`groupnode_id`),
   KEY `node_id` (`node_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='User_Nodes';


--
-- Constraints for table `groupnode_node`
--
ALTER TABLE `groupnode_node`
   ADD CONSTRAINT `groupnode_node_ibfk_1` FOREIGN KEY (`groupnode_id`) 
REFERENCES `groupnode` (`groupnode_id`),
   ADD CONSTRAINT `groupnode_node_ibfk_2` FOREIGN KEY (`node_id`) 
REFERENCES `node` (`node_id`);



--
-- Table structure for table `groupnode`
--

CREATE TABLE IF NOT EXISTS `groupnode` (
   `groupnode_id` int(10) NOT NULL auto_increment COMMENT 'PK',
   `groupnode_name` varchar(64) collate utf8_unicode_ci NOT NULL COMMENT 
'Name of the Project (SIM)',
   `groupnode_status` enum('active','deactivated','deleted') collate 
utf8_unicode_ci NOT NULL default 'active',
   `groupnode_comment` text collate utf8_unicode_ci COMMENT 'description 
of the group',
   PRIMARY KEY  (`groupnode_id`),
   UNIQUE KEY `groupnode_name` (`groupnode_name`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 
COMMENT='groupnode' AUTO_INCREMENT=3 ;





--
-- Table structure for table `node`
--

CREATE TABLE IF NOT EXISTS `node` (
   `node_id` int(10) NOT NULL auto_increment COMMENT 'PK',
   `server_id` int(10) default NULL COMMENT 'FK servers',
   `node_name` varchar(64) collate utf8_unicode_ci NOT NULL COMMENT 
'node name',
   `node_status` enum('requested','active','deactivated','deleted') 
collate utf8_unicode_ci NOT NULL default 'active',
   `node_sysuse` enum('desktop','server') collate utf8_unicode_ci 
default 'desktop',
   `node_estimatedBuAmount` int(64) default NULL COMMENT 'estimated 
BU/Archiv amount (GB) - up 2',
   `node_schedule` varchar(64) collate utf8_unicode_ci default NULL 
COMMENT 'Point in time when BU has 2 be started',
   `node_cpu` tinyint(4) default '1',
   `node_comment` text collate utf8_unicode_ci,
   PRIMARY KEY  (`node_id`),
   UNIQUE KEY `node_name` (`node_name`),
   KEY `server_id` (`server_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 
COMMENT='Nodes' AUTO_INCREMENT=37 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `node`
--
ALTER TABLE `node`
   ADD CONSTRAINT `node_ibfk_1` FOREIGN KEY (`server_id`) REFERENCES 
`server` (`server_id`);



So, I'm grateful for any hints, thanx ;-)



More information about the Catalyst mailing list