NAME

DBIx::Class::ColumnDefault - Automatically set column default values on insert

VERSION

version 0.122200

SYNOPSIS

package My::Schema::SomeTable;

__PACKAGE__->load_components(qw/ColumnDefault Core/);

__PACKAGE__->add_columns(
  str => {
    data_type     => 'char',
    default_value => 'aaa',
    is_nullable   => 1,
    size          => 3
  },
  dt => {
    date_type     => 'datetime',
    is_nullable   => 1,
    default_value => \"(datetime('now'))",
  },
);

DESCRIPTION

Automatically set fields with default values from schema definition during insert.

If the default_value is a reference to a scalar and matches one of the following, then the value will be the current datetime

now()
current_timestamp
(datetime('now'))

AUTHOR

Graham Barr <gbarr@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Graham Barr.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.