DBIx::C...:Writing(3)

πŸ¦‹ DBIx::Class::Schema::Loader::DBI::Writing(3) πŸ¦‹

okay so bestie, this is the DBIx::Class::Schema::Loader::DBI::Writing page from the User Contributed Perl Documentation β€” it's the loader subclass writing guide for DBI, and we're making it make sense together πŸ’…βœ¨

✨ NAME ✨

DBIx::Class::Schema::Loader::DBI::Writing β€” Loader subclass writing guide for DBI 🫢

🌸 SYNOPSIS 🌸

okay so here's the starter template β€” not me being obsessed with a template, but it's literally there to get you started, no cap:

package DBIx::Class::Schema::Loader::DBI::Foo;

# THIS IS JUST A TEMPLATE TO GET YOU STARTED.

use strict;
use warnings;
use base 'DBIx::Class::Schema::Loader::DBI';
use mro 'c3';

sub _table_uniq_info {
    my ($self, $table) = @_;

    # ... get UNIQUE info for $table somehow
    # and return a data structure that looks like this:

    return [
         [ 'keyname' => [ 'colname' ] ],
         [ 'keyname2' => [ 'col1name', 'col2name' ] ],
         [ 'keyname3' => [ 'colname' ] ],
    ];

    # Where the "keyname"'s are just unique identifiers, such as the
    # name of the unique constraint, or the names of the columns involved
    # concatenated if you wish.
}

sub _table_comment {
    my ( $self, $table ) = @_;
    return 'Comment';
}

sub _column_comment {
    my ( $self, $table, $column_number ) = @_;
    return 'Col. comment';
}

1;

πŸ¦‹ DETAILS πŸ¦‹

the way that _table_uniq_info is the only required method for new subclasses? lowkey iconic. bestie, there is not (yet) any standardized, DBD-agnostic way to get this info from DBI, so that's the whole reason 😭

the base DBI Loader has generic methods that should work for everything else in theory β€” main character energy β€” although in practice some DBDs need to override one or more of the other methods. the other methods you might likely wanna override are: _table_pk_info, _table_fk_info, _tables_list and _extra_column_info. see the included DBD drivers for examples of these, they ate that πŸ’…

to import comments from the database you need to implement _table_comment, _column_comment β€” yes both, bestie, don't skip one 🌈

πŸ‘‘ AUTHORS πŸ‘‘

see "AUTHORS" in DBIx::Class::Schema::Loader 🫢 go give the icons their credit πŸ’–

πŸ’œ LICENSE πŸ’œ

legal cutie moment: This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt, fr fr πŸ’…


πŸŽ€ cute sign-off: this page is from perl v5.42.0, dated 2025-07-25, and it's the DBIx::Class::Schema::Loader::DBI::Writing(3) manual. bye bestie, go write that subclass πŸ’…βœ¨
πŸ“¦ where this page comes from