Subject: | Failing to replace -- comments correctly |
While trying to upgrade using a sql script like the following:
--
-- Table structure for table `user_roles`
--
CREATE TABLE `user_roles` (
`user_id` int(11) NOT NULL DEFAULT '0',
`role_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
VersionedDDL creates the schema_version and inserts a success value, however the table is
not created.
It looks like the comment sequence is not being removed correctly and instead results in the
whole command (up to the semicolon) being parsed by MySQL as one long comment.
I believe it is due to the way the comments are substituted ( $ddl =~ s/--.*$/ /g; ).
If I add the m option to the pattern match (to treat the string as multiple lines) this seems to
fix the problem ( $ddl =~ s/--.*$/ /mg; ).
It would also be handy if you could add other comment styles as I often see the # character
used within scripts for one liners.
This page lists the styles for MySQL:
http://dev.mysql.com/doc/refman/5.1/en/comments.html
Many thanks for your work on this - the module is extremely handy!.
Distribution name: DBIx-VersionedDDL-0.05
Perl Version: v5.10.1
Operating System: FreeBSD 8.0-RELEASE