X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=ec8948efa25f5cfa3eb2e0d70d17a21e555ae2fd;hb=19feb86bd0beb518ffb5bcbfe3cf37d2cc9c1c21;hp=5618980f5fc6366ac913bc83d30f67d42407e270;hpb=362500af8a426f6dbe3531583e331a9380e4feea;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 5618980..ec8948e 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -438,6 +438,44 @@ And import using the mysql client: mysql -h "host" -D "database" -u "user" -p < Schema1.sql +=head2 Easy migration from class-based to schema-based setup + +You want to start using the schema-based approach to L +(see L), but have an established class-based setup with lots +of existing classes that you don't want to move by hand. Try this nifty script +instead: + + use MyDB; + use SQL::Translator; + + my $schema = MyDB->schema_instance; + + my $translator = SQL::Translator->new( + debug => $debug || 0, + trace => $trace || 0, + no_comments => $no_comments || 0, + show_warnings => $show_warnings || 0, + add_drop_table => $add_drop_table || 0, + validate => $validate || 0, + parser_args => { + 'DBIx::Schema' => $schema, + } + producer_args => { + 'prefix' => 'My::Schema', + } + ); + + $translator->parser('DBIx::Class'); + $translator->producer('DBIx::Class::File'); + + my $output = $translator->translate(@args) or die + "Error: " . $translator->error; + + print $output; + +You could use L to search for all subclasses in the MyDB::* +namespace, which is currently left as an excercise for the reader. + =head2 Schema versioning The following example shows simplistically how you might use DBIx::Class to