{"id":14973882,"url":"https://github.com/renoki-co/laravel-thermite","last_synced_at":"2025-10-27T02:31:36.337Z","repository":{"id":37980609,"uuid":"386672830","full_name":"renoki-co/laravel-thermite","owner":"renoki-co","description":"Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster.","archived":false,"fork":false,"pushed_at":"2023-10-23T07:03:15.000Z","size":61,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-28T18:05:04.036Z","etag":null,"topics":["active","cockroach","cockroachdb","database","laravel","pgsql","postgres","postgresql","psql","replica"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renoki-co.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"rennokki"}},"created_at":"2021-07-16T14:54:04.000Z","updated_at":"2023-11-09T18:52:10.000Z","dependencies_parsed_at":"2024-01-12T02:14:12.395Z","dependency_job_id":null,"html_url":"https://github.com/renoki-co/laravel-thermite","commit_stats":{"total_commits":48,"total_committers":4,"mean_commits":12.0,"dds":0.5208333333333333,"last_synced_commit":"2c20986271815b085b443c9d259b5de34b7cee27"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":"renoki-co/laravel-package-skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Flaravel-thermite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Flaravel-thermite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Flaravel-thermite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renoki-co%2Flaravel-thermite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renoki-co","download_url":"https://codeload.github.com/renoki-co/laravel-thermite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861968,"owners_count":16555980,"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":["active","cockroach","cockroachdb","database","laravel","pgsql","postgres","postgresql","psql","replica"],"created_at":"2024-09-24T13:49:37.799Z","updated_at":"2025-10-27T02:31:36.042Z","avatar_url":"https://github.com/renoki-co.png","language":"PHP","funding_links":["https://github.com/sponsors/rennokki"],"categories":[],"sub_categories":[],"readme":"Laravel Thermite\n================\n\n![CI](https://github.com/renoki-co/laravel-thermite/workflows/CI/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/renoki-co/laravel-thermite/branch/master/graph/badge.svg)](https://codecov.io/gh/renoki-co/laravel-thermite/branch/master)\n[![StyleCI](https://github.styleci.io/repos/386672830/shield?branch=master)](https://github.styleci.io/repos/386672830)\n[![Latest Stable Version](https://poser.pugx.org/renoki-co/laravel-thermite/v/stable)](https://packagist.org/packages/renoki-co/laravel-thermite)\n[![Total Downloads](https://poser.pugx.org/renoki-co/laravel-thermite/downloads)](https://packagist.org/packages/renoki-co/laravel-thermite)\n[![Monthly Downloads](https://poser.pugx.org/renoki-co/laravel-thermite/d/monthly)](https://packagist.org/packages/renoki-co/laravel-thermite)\n[![License](https://poser.pugx.org/renoki-co/laravel-thermite/license)](https://packagist.org/packages/renoki-co/laravel-thermite)\n\nLaravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster.\n\n## 🤝 Supporting\n\n**If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with [Github Sponsors](https://github.com/sponsors/rennokki). 📦**\n\n[\u003cimg src=\"https://github-content.s3.fr-par.scw.cloud/static/27.jpg\" height=\"210\" width=\"418\" /\u003e](https://github-content.renoki.org/github-repo/27)\n\n## 🚀 Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require renoki-co/laravel-thermite\n```\n\n## 🙌 Usage\n\nThe driver is based on Postgres, most of the features from Laravel's first-party Postgres driver are available in CockroachDB.\n\n```php\n// config/database.php\n\nreturn [\n    // ...\n\n    'connections' =\u003e [\n        // ...\n\n        'cockroachdb' =\u003e [\n            'driver' =\u003e 'cockroachdb',\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', 'defaultdb'),\n            'username' =\u003e env('DB_USERNAME', 'root'),\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    ],\n];\n```\n\n## ✨ Caveats\n\n### Primary Keys are not incremental\n\nPostgres supports incrementing keys, but since CockroachDB is based on a global multi-master architecture, having increments may lead to [transaction contention](https://www.cockroachlabs.com/docs/v21.1/sql-faqs#how-do-i-auto-generate-unique-row-ids-in-cockroachdb).\n\nThis way, this extended driver leverages you with two functions that you may call in your migrations to generate performant, unique IDs. The differences between the methods [can be found here](https://www.cockroachlabs.com/docs/v21.1/sql-faqs#what-are-the-differences-between-uuid-sequences-and-unique_rowid).\n\nThe `-\u003eid()` method got replaced to generate a random UUID as primary key with `gen_random_uuid()` instead of an incremental primary key. The downside is that is not orderable, opposed to `uniqueRowId()`:\n\n```php\nuse RenokiCo\\LaravelThermite\\Database\\Blueprint;\n\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eid();\n    $table-\u003estring('name');\n});\n\nclass User extends Model\n{\n    // Make sure to set key type as string.\n    protected $keyType = 'string';\n}\n```\n\nWith `uniqueRowId()`, it uses `unique_rowid()`-generated primary key. This is highly-orderable, being sequentially generated. The only minor downsides are the throttling upon insert, which are limited by one node.\n\n```php\nuse RenokiCo\\LaravelThermite\\Database\\Blueprint;\n\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003euniqueRowId();\n    $table-\u003estring('name');\n});\n\nclass User extends Model\n{\n    // Do not set the $keyType to string, as it is an integer.\n}\n```\n\n### Foreign keys associated with Primary Keys\n\nTo represent the primary key constraints in other tables, like passing relational fields, consider using `-\u003euuid()`:\n\n```php\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eid();\n    $table-\u003estring('name');\n});\n\nSchema::create('books', function (Blueprint $table) {\n    $table-\u003eid();\n    $table-\u003euuid('user_id')-\u003eindex();\n    $table-\u003estring('name');\n});\n\n$book = $user-\u003ebooks()-\u003ecreate(['name' =\u003e 'The Great Gatsby']);\n```\n\n## Other caveats\n\nBeing based on Postgres, CockroachDB borrowed functionalities from its code. Consider [reading about CockroachDB-Postgres compatibilities](https://www.cockroachlabs.com/docs/v21.1/sql-feature-support.html) when it comes to schema capabilities and counter-patterns that may affect your implementation and [see further caveats that are CockroachDB-only](https://www.cockroachlabs.com/docs/v21.1/postgresql-compatibility.html).\n\n## 🐛 Testing\n\n``` bash\nvendor/bin/phpunit\n```\n\n## 🤝 Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## 🔒  Security\n\nIf you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.\n\n## 🎉 Credits\n\n- [Alex Renoki](https://github.com/rennokki)\n- [All Contributors](../../contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenoki-co%2Flaravel-thermite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenoki-co%2Flaravel-thermite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenoki-co%2Flaravel-thermite/lists"}