https://github.com/colopl/laravel-tidb
Laravel database driver for PingCAP TiDB
https://github.com/colopl/laravel-tidb
laravel php tidb
Last synced: about 2 months ago
JSON representation
Laravel database driver for PingCAP TiDB
- Host: GitHub
- URL: https://github.com/colopl/laravel-tidb
- Owner: colopl
- License: apache-2.0
- Created: 2021-12-03T07:56:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T01:31:07.000Z (about 1 year ago)
- Last Synced: 2025-03-24T09:11:31.176Z (3 months ago)
- Topics: laravel, php, tidb
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 21
- Watchers: 9
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
laravel-tidb
================Laravel database driver for [TiDB](https://github.com/pingcap/tidb)
## Requirements
- PHP >= 7.4
- Laravel 6 ~ 10
- TiDB >= 4.0## Installation
Install via composer
```sh
composer require colopl/laravel-tidb
```That's all. You can use database connection as usual.
## Features
- Added `autoRandom($shard_bits = null)` to `ColumnDefinition`
- When user defines `$table->id()` in the migration file, it will add `PRIMARY KEY AUTO_RANDOM` to the schema instead of `PRIMARY KEY AUTO_INCREMENT` so that data gets distributed evenly.
- Added Support for nested transactions (MySQL driver will throw an exception)
- Added Support for adding/dropping multiple columns (MySQL driver will throw an exception)## Unsupported features
1. Nesting transactions and then rolling them back will always rollback to the first transaction since `SAVEPOINT` is not supported by TiDB. In other words, rolling back with `$connection->rollBack()` will always rollback level to `0`.
2. Adding and dropping multiple columns atomically is not fully supported. Defining multiple columns in migrations is supported but will be executed one by one and will not be atomic. Ex: `$table->dropColumn('title', 'content')`For unsupported features for TiDB itself, please see [MySQL Compatibility](https://docs.pingcap.com/tidb/stable/mysql-compatibility).
### Testing
You can run tests on docker by the following command.```sh
make test
```## License
Apache 2.0 - See [LICENSE](./LICENSE) for more information.