{"id":20101357,"url":"https://github.com/ylsideas/cockroachdb-laravel","last_synced_at":"2025-08-20T03:31:04.116Z","repository":{"id":41873678,"uuid":"435197675","full_name":"ylsideas/cockroachdb-laravel","owner":"ylsideas","description":"A driver for compatibility between Laravel and CockroachDB","archived":false,"fork":false,"pushed_at":"2024-04-29T11:57:39.000Z","size":314,"stargazers_count":54,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T21:08:33.949Z","etag":null,"topics":["cockroachdb","database","hacktoberfest","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ylsideas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"peterfox"}},"created_at":"2021-12-05T14:59:38.000Z","updated_at":"2024-07-08T14:12:35.929Z","dependencies_parsed_at":"2023-12-01T23:28:38.742Z","dependency_job_id":"55a1691a-3879-4644-afa4-38133fe0cde4","html_url":"https://github.com/ylsideas/cockroachdb-laravel","commit_stats":{"total_commits":53,"total_committers":4,"mean_commits":13.25,"dds":"0.37735849056603776","last_synced_commit":"13c1d74848ad3d98aa2962b9f8c047d61a586f51"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ylsideas%2Fcockroachdb-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ylsideas%2Fcockroachdb-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ylsideas%2Fcockroachdb-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ylsideas%2Fcockroachdb-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ylsideas","download_url":"https://codeload.github.com/ylsideas/cockroachdb-laravel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230388131,"owners_count":18217755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cockroachdb","database","hacktoberfest","laravel","php"],"created_at":"2024-11-13T17:24:48.811Z","updated_at":"2024-12-19T06:09:18.324Z","avatar_url":"https://github.com/ylsideas.png","language":"PHP","funding_links":["https://github.com/sponsors/peterfox"],"categories":[],"sub_categories":[],"readme":"# CockroachDB Driver for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/ylsideas/cockroachdb-laravel.svg?style=flat-square)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)\n[![PHPUnit Tests](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/run-tests.yml)\n[![Check \u0026 fix styling](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/pint.yml/badge.svg)](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/pint.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/ylsideas/cockroachdb-laravel.svg?style=flat-square)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)\n[![codecov](https://codecov.io/github/ylsideas/cockroachdb-laravel/branch/main/graph/badge.svg?token=GCCY3KZHXQ)](https://codecov.io/github/ylsideas/cockroachdb-laravel)\n[![Help Fund](https://img.shields.io/github/sponsors/peterfox?style=flat-square)](https://github.com/sponsors/peterfox)\n[![License](http://poser.pugx.org/ylsideas/cockroachdb-laravel/license)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)\n[![PHP Version Require](http://poser.pugx.org/ylsideas/cockroachdb-laravel/require/php)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)\n\nA driver/grammar for Laravel that works with CockroachDB. While CockroachDB is compatible with Postgresql, this support\nis not 1 to 1 meaning you may run into issues, this driver hopes to resolve those problems as much as possible.\n\nLaravel 9 through to Laravel 11 is supported and tested against CockroachDB 22 \u0026 23.\n\n### Supporting Open Source\n\n[Peter Fox](https://www.peterfox.me) here, I just want to say this project has been my hardest yet. It's been a real labour of love to make and takes\nup a lot of time trying to organise the test suite so that compatibility is maintained between Eloquent and CockroachDB.\n\nI see a lot of promise in using CockroachDB's serverless offering which is what compelled me to go down this route originally.\nYou can read [an article](https://medium.com/@SlyFireFox/laravel-tip-cockroachdbs-serverless-database-322aa7f5f7ef) \nI made about using their service.\n\nIf you're using this project at all then do please consider [sponsoring me](https://github.com/sponsors/peterfox) \nas a way of encouraging more development.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require ylsideas/cockroachdb-laravel\n```\n\nYou need to add the connection type to the database config:\n```php\n'crdb' =\u003e [\n    'driver' =\u003e 'crdb',\n    'url' =\u003e env('DATABASE_URL'),\n    'host' =\u003e env('DB_HOST', '127.0.0.1'),\n    'port' =\u003e env('DB_PORT', '26257'),\n    'database' =\u003e env('DB_DATABASE', 'forge'),\n    'username' =\u003e env('DB_USERNAME', 'forge'),\n    'password' =\u003e env('DB_PASSWORD', ''),\n    'charset' =\u003e 'utf8',\n    'prefix' =\u003e '',\n    'prefix_indexes' =\u003e true,\n    'schema' =\u003e 'public',\n    'sslmode' =\u003e 'prefer',\n]\n```\n\nYou can also use URLs.\n\n```dotenv\nDATABASE_URL=cockroachdb://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e/\u003cdatabase\u003e?sslmode=verify-full\n```\n\n## Usage\n\nTo enable set `DB_CONNECTION=crdb` in your .env.\n\n## Notes\n\nCockroachDB should work inline with the feature set of Postgresql, with some exceptions. You can look at the\nfeatures of each CockroachDB server in the CockroachDB [Docs](https://www.cockroachlabs.com/docs/stable/sql-feature-support.html).\n\n### Deletes with Joins\nCockroachDB does not support performing deletes using joins. If you wish to\ndo something like this you will need to use a sub-query instead.\n\nAt current if you try to call the `delete` method of the Query builder together with a `join` then\na `YlsIdeas\\CockroachDb\\Exceptions\\FeatureNotSupportedException` exception will be thrown.\n\n### Fulltext Search\nEloquent and Postgresql support Fulltext search. CockroachDB does not support any full text\nsearch meaning the feature cannot be used when using this driver.\n\nAt current if you try to create a Fulltext index using the Schema builder or try to use the `whereFulltext`\nmethod of the Query builder a `YlsIdeas\\CockroachDb\\Exceptions\\FeatureNotSupportedException` exception will be thrown.\n\n### Serverless Support\nCockroach Serverless requires you to provide a cluster with connection.\nLaravel doesn't provide this out of the box, so, it's being implemented as an extra `cluster` parameter in the \ndatabase config. Just pass the cluster identification from CockroachDB Serverless.\n\n### Schema Dumps\nYou may use schema dumps. I'm not 100% sure the functionality is correct in line with other drivers.\nPlease raise an issue if it isn't working as expect for you.\n\n```php\n'crdb' =\u003e [\n    'driver' =\u003e 'crdb',\n    'url' =\u003e env('DATABASE_URL'),\n    'host' =\u003e env('DB_HOST', '127.0.0.1'),\n    'port' =\u003e env('DB_PORT', '26257'),\n    'database' =\u003e env('DB_DATABASE', 'forge'),\n    'username' =\u003e env('DB_USERNAME', 'forge'),\n    'password' =\u003e env('DB_PASSWORD', ''),\n    'charset' =\u003e 'utf8',\n    'prefix' =\u003e '',\n    'prefix_indexes' =\u003e true,\n    'schema' =\u003e 'public',\n    'sslmode' =\u003e 'prefer',\n    'cluster' =\u003e env('COCKROACHDB_CLUSTER', ''),\n]\n```\n\nYou may also use a URL in the following format.\n\n```dotenv\nDATABASE_URL=cockroachdb://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e/\u003cdatabase\u003e?sslmode=verify-full\u0026cluster=\u003ccluster\u003e\n```\n\n## Testing\n\nThe tests try to closely follow the same functionality of the grammar provided by Laravel\nby lifting the tests straight from laravel/framework. This does provide some complications.\nNamely, cockroachdb is designed to be distributed so primary keys do not occur in sequence.\n\nTests should also try to be compatible with not just the latest version of Laravel but across\nLaravel 8, 9 and 10, this requires some tests to be skipped.\n\nYou can run up a local cockroachDB test instance using Docker compose.\n```shell\ndocker-composer up -d\n```\n\nIf you need to you may run the docker compose file with different cockroachdb\nversions\n```shell\nVERSION=v23.1.13 docker-compose up -d\n```\n\nThen run the following PHP script to create a test database and user\n```shell\nphp ./database.php\n```\n\nAfterwards you can run the test suite.\n```bash\ncomposer test\n```\n\nTo clean up, you only need stop docker composer.\n```shell\ndocker-composer down\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Peter Fox](https://github.com/peterfox)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fylsideas%2Fcockroachdb-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fylsideas%2Fcockroachdb-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fylsideas%2Fcockroachdb-laravel/lists"}