glushkovds / php-clickhouse-schema-builder
PHP library for generating DDL statements for ClickHouse
Installs: 2 649
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9
README
ClickHouse schema builder written in PHP
Requirements
- PHP 8.0
Installation
1. Install via composer
$ composer require glushkovds/php-clickhouse-schema-builder
Usage
use PhpClickHouseSchemaBuilder\Tables\MergeTree; $ddl = (new MergeTree('some_table')) ->dbName('some_db') // optional, for replicated table engine ->onCluster('some_cluster') ->columns(fn(MergeTree $t) => [ $t->string('col_one')->default('5')->comment('some comment'), $t->datetime('at'), ]) ->orderBy('col_one') ->partition('toDate(at)') ->ttl('at', '1 month') ->engine((new Engine(Engine::REPLACING_MERGE_TREE))->replicated(), 'col_one') ->settings(['ttl_only_drop_parts' => 1, 'index_granularity' => 8192]) ->compile();