[Dbix-class] create_ddl_dir with MySQL / InnoDB

Ash Berlin ash_cpan at firemirror.com
Fri Jun 6 16:20:22 BST 2008


On 6 Jun 2008, at 15:36, Juan Camacho wrote:

> I would really like to use the new schema version functionality, but
> ran into a problem when the schema is generated for MySQL.  The
> generated SQL contain CONSTRAINT clauses that cause an error.  Is
> there a way to completely disable them?
>
> $schema->create_ddl_dir(['MySQL'], '1.1', './sql', 0, {producer_args
> => {mysql_table_type => 'MyISAM'}});
>
> For example:
>
> CREATE TABLE `attendee` (
>  `attendee_id` integer(10) NOT NULL,
>  `company_id` integer(10) NOT NULL DEFAULT '0',
>  `name` VARCHAR(255) NOT NULL DEFAULT '',
>  `first` VARCHAR(100),
>  `last` VARCHAR(100),
>  `title` VARCHAR(100),
>  `bank_rep` integer(10) DEFAULT '0',
>  `email` VARCHAR(100),
>  `foreign_id` VARCHAR(32),
>  INDEX attendee_idx_company_id (`company_id`),
>  PRIMARY KEY (`attendee_id`),
>  UNIQUE `name_company_idx` (`company_id`, `name`),
>  CONSTRAINT `attendee_fk_company_id` FOREIGN KEY (`company_id`)
> REFERENCES `company` (`company_id`) ON DELETE CASCADE ON UPDATE CAS
> CADE
> ) ENGINE=InnoDB;
>
> FYI, I'm using the development release (0.08099_02) that's on CPAN,
> since I realized that the regular release doesn't pass arguments
> forward.
>

What error is it giving? What version of MySQL (server) are you using?

That isn't where mysql_table_type goes - you want something like this  
in your Schema.pm file (assuming you got the extra key right - i  
didn't check)

sub sqlt_deploy_hook {
   my ($self, $sqlt_schema) = @_;

   for my $table ($sqlt_schema->get_tables) {
     $table->extra(
       mysql_table_type => 'MyISAM',
     );
   }
}

HTH
-ash




More information about the DBIx-Class mailing list