Skip to content

Instantly share code, notes, and snippets.

@sng2c
Created December 17, 2013 06:09
Show Gist options
  • Select an option

  • Save sng2c/8000776 to your computer and use it in GitHub Desktop.

Select an option

Save sng2c/8000776 to your computer and use it in GitHub Desktop.
DBIC dump schema script.
---
database:
dsn: DBI:mysql:database=DBNAME;host=DBHOST
userid: DBUSER
passwd: DBPASS
options:
mysql_enable_utf8: 1
mysql_auto_reconnect: 1
#!/usr/bin/env perl
my $base_package = 'MyClass::Schema';
my $dump_directory = './lib';
### use this module to generate a set of class files
use YAML;
my $config = YAML::LoadFile('config.yaml');
my $db = $config->{database};
# in a script
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
make_schema_at(
$base_package,
{ debug => 1,
dump_directory => $dump_directory,
components => ['InflateColumn::DateTime', 'TimeStamp'],
},
[
$db->{dsn},
$db->{userid},
$db->{passwd},
$db->{options},
],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment