NAME
DBIO::UUIDColumns - Automatically populate UUID columns on insert
VERSION
version 0.900000
SYNOPSIS
package MyApp::Schema::Result::Artist;
use base 'DBIO::Core';
__PACKAGE__->load_components(qw/UUIDColumns/);
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(
artist_id => { data_type => 'varchar', size => 36, uuid_on_create => 1 },
name => { data_type => 'varchar', size => 100 },
);
__PACKAGE__->set_primary_key('artist_id');
DESCRIPTION
Automatically populates columns flagged with uuid_on_create => 1 with a freshly generated UUID on insert. Existing values are respected -- only undefined columns receive a generated UUID.
The generator backend is selected per class via "uuid_class". By default the first installed backend among Data::UUID, UUID, and UUID::Random is used. Loading this component throws if none of these modules are available.
Based on DBIx::Class::UUIDColumns by Chia-liang Kao and Chris Laco.
METHODS
uuid_class
__PACKAGE__->uuid_class('Data::UUID');
Class-level accessor. Selects the UUID generator backend. Defaults to the first installed backend among Data::UUID, UUID, and UUID::Random.
get_uuid
Returns one freshly generated UUID string from the configured backend. Override this in your Result class to customize.
COLUMN FLAGS
uuid_on_create => 1-
The column receives a freshly generated UUID on insert if no value was supplied.
OVERRIDABLE METHODS
get_uuid-
Returns one freshly generated UUID string from the configured backend. Override in your Result class to customize.
uuid_class($class)-
Class-level accessor for the generator backend. Pass a class name to switch backend (e.g.
'Data::UUID').
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.