App-Sqitch

 view release on metacpan or  search on metacpan

lib/App/Sqitch/Engine/cockroach.pm  view on Meta::CPAN

package App::Sqitch::Engine::cockroach;

use 5.010;
use Moo;
use namespace::autoclean;

extends 'App::Sqitch::Engine::pg';

our $VERSION = 'v1.6.1'; # VERSION

sub key    { 'cockroach' }
sub name   { 'CockroachDB' }
sub driver { 'DBD::Pg 2.0' }

sub _ts2char_format {
    q{experimental_strftime(%s AT TIME ZONE 'UTC', 'year:%%Y:month:%%m:day:%%d:hour:%%H:minute:%%M:second:%%S:time_zone:UTC')};
}

# Override to avoid locking the changes table, as Cockroach does not support
# explicit table locks.
sub begin_work {
    my $self = shift;
    $self->dbh->begin_work;
    return $self;
}

# Override to return true, as Cockroach does not support advisory locks.
sub wait_lock {
    # Cockroach does not support advisory locks.
    # https://github.com/cockroachdb/cockroach/issues/13546
    return 1;
}

sub _no_table_error  {
    $DBI::state && $DBI::state eq '42P01'; # undefined_table
}

sub _run_registry_file {
    my ($self, $file) = @_;
    my $schema = $self->registry;

    $self->_run(
        '--file' => $file,
        '--set'  => "registry=$schema",
    );

    $self->dbh->do('SET search_path = ?', undef, $schema);
}

1;

__END__

=head1 Name

App::Sqitch::Engine::cockroach - Sqitch CockroachDB Engine

=head1 Synopsis

  my $pg = App::Sqitch::Engine->load( engine => 'cockroach' );

=head1 Description

App::Sqitch::Engine::cockroach provides the CockroachDB storage engine for Sqitch. It
supports CockroachDB v21 and higher, and relies on the Postgres toolchain (C<psql>



( run in 0.760 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )