=pod

=encoding utf8

=head1 NAME

Memorator::Backend::Mojo::SQLite - backend for Mojo::SQLite

=head1 SYNOPSIS

   # in typical usage, this class is used automatically
   use Minion;
   use Memorator;
   my $minion = Minion->new(SQLite => 'sqlite:test.db');
   my $memorator = Memorator->create(
      minion => $minion, # <-- this is it
      ...
   );

   # The "explicit way" might imply using different databases
   # for Minion and this class
   use Mojo::SQLite;
   use Memorator::Backend::Mojo::SQLite;
   my $sqlite = Mojo::SQLite->new('sqlite:test.db');
   my $memsqlite = Memorator::Backend::Mojo::SQLite->new(
      mojodb => $sqlite,     # mandatory
      name   => 'whatever',  # mandatory
   );

   # ... then, for Memorator...
   use Memorator;
   my $memorator = Memorator->create(
      backend => $memsqlite, # <-- this is it
      ...
   );

=head1 DESCRIPTION

This class allows you to use L<Mojo::SQLite> as a backend for keeping the
mapping between external identifiers and job identifiers. It heavily
relies on L<Memorator::Backend>, that is its parent class, so it inherits
all of its methods while implementing L</migration>, that allows setting
up the table in the database.

You don't generally need to use this class directly, as it is used behind
the scenes automatically by L<Memorator> when you set a L<Minion> that
relies upon L<Mojo::SQLite>. It's anyway good to have around if you need to do
non-standard things, like e.g. use different database technologies for the
L<Minion> backend and L<Memorator> backend.

=head1 METHODS

This class inherits all methods from L<Memorator::Backend>, adding the
following one.

=head2 B<< migration >>

   my $text = $obj->migration;

get the text suitable to create the database table(s) via
L<Mojo::SQLite/migrations>. It relies upon
L<Memorator::Backend/table_name> to set the name of the table to be
created.

=begin TRICK

These methods are inherited from L<Memorator::Backend>, but for some
reason Test::Pod::Coverage complains about missing documentation for them.

=over

=item add_mapping

=item deactivate_mapping

=item deactivate_mapping_query

=item ensure_table

=item mapping_between

=item mapping_between_query

=item remove_mapping

=item stale_mappings

=item stale_mappings_query

=item table_name

=back

=end TRICK

=head1 SEE ALSO

L<Memorator::Backend>.

=head1 AUTHOR

Flavio Poletti <polettix@cpan.org>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2018 by Flavio Poletti <polettix@cpan.org>

This module is free software. You can redistribute it and/or modify it
under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.

=cut
