colopl / laravel-tidb
Laravel database driver for PingCAP TiDB
Installs: 4 149
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 9
Forks: 4
Open Issues: 0
Requires
- php: >=8
- ext-json: *
- ext-pdo: *
- laravel/framework: ~10|~11
Requires (Dev)
- orchestra/testbench: ~8|~9
- phpunit/phpunit: ~11
README
Laravel database driver for TiDB
Requirements
- PHP >= 7.4
- Laravel 6 ~ 10
- TiDB >= 4.0
Installation
Install via composer
composer require colopl/laravel-tidb
That's all. You can use database connection as usual.
Features
- Added
autoRandom($shard_bits = null)
toColumnDefinition
- When user defines
$table->id()
in the migration file, it will addPRIMARY KEY AUTO_RANDOM
to the schema instead ofPRIMARY 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
- 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 to0
. - 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.
Testing
You can run tests on docker by the following command.
make test
License
Apache 2.0 - See LICENSE for more information.