DBIO

 view release on metacpan or  search on metacpan

lib/DBIO/Cake.pm  view on Meta::CPAN

=head2 rel_many

Alias for C<has_many>.

=head1 CASCADE HELPERS

=head2 ddl_cascade

Returns C<on_delete =E<gt> 'CASCADE', on_update =E<gt> 'CASCADE'> for use in
relationship attribute hashes.

=head2 dbic_cascade

Returns C<cascade_delete =E<gt> 1, cascade_copy =E<gt> 1>.

=head1 VIEW SUPPORT

=head2 view

  view 'my_view', 'SELECT * FROM artists WHERE active = 1';

Declares a view-based result source.

=head1 TIMESTAMP HELPERS

Shortcut functions for the most common timestamp column patterns.

=head2 col_created

  col_created;               # creates 'created_at' column
  col_created 'born_at';     # custom column name

Equivalent to C<col created_at =E<gt> timestamp>.

=head2 col_updated

  col_updated;               # creates 'updated_at' column
  col_updated 'modified_at'; # custom column name

Equivalent to C<col updated_at =E<gt> timestamp on_update>.

=head2 cols_updated_created

  cols_updated_created;      # creates both created_at + updated_at

Creates both timestamp columns in one call. The most common pattern --
just add this one line and you're done.

=head1 INDEX SUPPORT

=head2 idx

  idx name_idx => ['name'];
  idx composite_idx => ['last_name', 'first_name'], type => 'unique';
  idx tags_idx => ['tags'], using => 'gin';
  idx draft_only => ['key'],
      type => 'unique',
      pg   => { where => 'version IS NULL' };

Declares an index. Cake installs two hooks on the Result class so that
C<idx> works transparently in both deployment pipelines:

=over

=item * C<sqlt_deploy_hook> — B<DEPRECATED> hook for legacy
deployment. The C<options> key passes producer-specific options through.

=item * C<pg_indexes> — used by L<DBIO::PostgreSQL::DDL> when the schema
loads the C<PostgreSQL> component. The C<pg> key carries
PostgreSQL-specific options (C<where>, C<using>, C<with>, C<expression>)
and is passed through to the native PG DDL emitter.

=back

If the class already defines C<pg_indexes> by hand, those definitions
are preserved and Cake-declared indexes are merged on top.

=head3 PostgreSQL partial indexes

  idx agent_published => ['key', 'version'],
      type => 'unique',
      pg   => { where => 'version IS NOT NULL' };
  idx agent_draft => ['key'],
      type => 'unique',
      pg   => { where => 'version IS NULL' };

=head1 SEE ALSO

L<DBIO::Core>, L<DBIO::Candy>, L<DBIO::ResultSource>,
L<DBIx::Class::ResultDDL> (inspiration for Cake's syntax)

=head1 AUTHOR

DBIO & DBIx::Class Authors

=head1 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.

=cut



( run in 3.131 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )