DBIx::Class::Smooth::ResultBase - Short intro
Version 0.0105, released 2020-09-20.
# in MyApp::Schema::Result::YourResultClass, instead of inheriting from DBIx::Class::Core use parent 'DBIx::Class::Smooth::Result::Base'; column last_name => { data_type => 'varchar', size => 150, indexed => 1, };
Adding indices (apart from primary keys and unique constraints) requires creating a sqlt_deploy_hook method and calling add_index manually. This module adds the indexed column attribute.
sqlt_deploy_hook
add_index
indexed
indexed behaves differently depending on the value it is given:
If given a one-character value, that evaluates to true, an index is created named [table_name]_idxa_[column_name].
[table_name]_idxa_[column_name]
If given a more-than-one-character value an index is created named [table_name]_idxm_[index_name]. If multiple columns are given the same name a composite index is created.
[table_name]_idxm_[index_name]
If given an array reference each value in it is treated according to the two rules above.
With these column definitions:
table('Author'); column first_name => { data_type => 'varchar', size => 150, indexed => 'name', }; column last_name => { data_type => 'varchar', size => 150, indexed => [1, 'name'], }; column country => { data_type => 'varchar', size => 150, indexed => 1, };
The following indices are created:
Author_idxm_name for first_name and last_name
Author_idxm_name
first_name
last_name
Author_idxa_last_name for last_name
Author_idxa_last_name
Author_idxa_country for country
Author_idxa_country
country
If you need an sqlt_deploy_hook method in a result source just call the parent's sqlt_deploy_hook in your local sqlt_deploy_hook:
sub sqlt_deploy_hook { my $self = shift; my $table = shift; $self->next::method($table); ... }
https://github.com/Csson/p5-DBIx-Class-Smooth
https://metacpan.org/release/DBIx-Class-Smooth
Erik Carlsson <info@code301.com>
This software is copyright (c) 2018 by Erik Carlsson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install DBIx::Class::Smooth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::Smooth
CPAN shell
perl -MCPAN -e shell install DBIx::Class::Smooth
For more information on module installation, please visit the detailed CPAN module installation guide.