I'm running
dbicdump -o dump_directory=./lib \
-o components='["InflateColumn::DateTime", "InflateColumn::Serializer"]' \
-o debug=1 \
-o db_schema=foo \
-o qualify_objects=1 \
Foo::Schema \
'dbi:Pg:dbname=foo' username password
against a Postgres database with the hopes that the generated schema will generate the code necessary to inflate timestamp and JSON column types.
Looking at the generated Schema files, I see the
__PACKAGE__->load_components("InflateColumn::Serializer", "InflateColumn::DateTime");
line, but now I have to add serializer_class => 'JSYNC'
to each of the JSON columns I want to inflate and deflate.
Is there a way to get dbicdump to do this automatically or is it expected practice to manually set these accessors?
Thanks!
Not sure this is possible from the dbicdump program, but if you use the the following perl program, you can do exactly what I want:
#!/usr/bin/env perl
use strict;
use warnings;
use DBIx::Class::Schema::Loader qw/make_schema_at/;
make_schema_at(
'Foo::Schema',
{
dump_directory => './lib',
components => [ "InflateColumn::Serializer", "InflateColumn::DateTime" ],
db_schema => 1,
qualify_objects => 1,
custom_column_info => sub {
my ($table, $column_name, $column_info) = @_;
if ( $column_info->{data_type} eq "json" ) {
return { serializer_class => "JSYNC" };
}
},
},
[
"dbi:Pg:dbname=foo',
"username",
"password"
]
);
Hope this saves someone some research time.