/doctrine-cockroach

Doctrine CockroachDB Driver

Primary LanguagePHPMIT LicenseMIT

Latest Stable Version Total Downloads PHP Version Require License

CockroachDB Driver

CockroachDB Driver is a Doctrine DBAL Driver to handle incompatibilities with PostgreSQL.

It is based on https://github.com/lapaygroup/doctrine-cockroachdb by Lapay Group.

CockroachDB Quick Setup Guide

Usage

# doctrine.yaml
doctrine:
    dbal:
        user: <user>
        port: <port(26257)>
        host: <host>
        dbname: <dbname>
        sslmode: verify-full
        sslrootcert: <path-to-ca.crt>
        sslcert: <path-to-user.crt>
        sslkey: <path-to-user.key>
        driver: pdo_pgsql
        driver_class: DoctrineCockroachDB\Driver\CockroachDBDriver

Unit testing

Start an insecure single-node instance:

cockroach start-single-node
  --store='type=mem,size=1GB' \
  --log='sinks: {stderr: {channels: [DEV]}}' \
  --listen-addr=127.0.0.1:26257 \
  --insecure \
  --accept-sql-without-tls

Connect to CockroachDB:

cockroach sql --host=127.0.0.1:26257 --insecure

Create the user & database for the tests:

CREATE USER "doctrine_tests";
CREATE DATABASE doctrine_tests OWNER "doctrine_tests";
USE doctrine_tests;
CREATE SCHEMA doctrine_tests AUTHORIZATION "doctrine_tests";
ALTER DATABASE doctrine_tests SET search_path = doctrine_tests;
GRANT ALL PRIVILEGES ON DATABASE doctrine_tests TO "doctrine_tests";
GRANT ALL PRIVILEGES ON SCHEMA doctrine_tests TO "doctrine_tests";

License

MIT