Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created May 29, 2019 14:52
Show Gist options
  • Select an option

  • Save jjn1056/7104d1141add2ef7e91b2e51faad4f17 to your computer and use it in GitHub Desktop.

Select an option

Save jjn1056/7104d1141add2ef7e91b2e51faad4f17 to your computer and use it in GitHub Desktop.
ub rebuild_schema {
my ($proto) = @_;
my $class = ref $proto || $proto;
my $target_dir = File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
my $tables = join('|', @TABLES);
my $constraint = qr/\A(?:$tables)\z/x;
my @args = (
$class,
{
debug => $ENV{CATME_SCHEMA_LOADER_DEBUG}||0,
generate_pod => 0,
use_namespaces => 1,
omit_version => 1,
omit_timestamp => 1,
default_resultset_class => 'DefaultRS',
result_base_class => 'CatmeSchema::Result',
dump_directory => $target_dir,
constraint => $constraint,
default_resultset_class => 'DefaultRS',
result_components_map => {
PersonNote => "InflateColumn::Serializer", # Don't need this component everywhere
},
custom_column_info => sub {
my ($table, $column_name, $column_info) = @_;
if($column_info->{data_type} eq 'json') {
return {
'serializer_options' => { allow_blessed => 1, convert_blessed => 1,},
'serializer_class' => 'JSON',
};
}
},
},
\@CatmeDb::DSN,
);
DBIx::Class::Schema::Loader::make_schema_at(@args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment