cybercog / laravel-clickhouse
ClickHouse migrations for Laravel
Fund package maintenance!
paypal.me/antonkomarev
Installs: 34 506
Dependents: 0
Suggesters: 0
Security: 0
Stars: 84
Watchers: 2
Forks: 13
Open Issues: 3
Requires
- php: ^7.4|^8.0
- illuminate/console: ^8.0|^9.0|^10.1.3|^11.0
- illuminate/contracts: ^8.0|^9.0|^10.1.3|^11.0
- illuminate/filesystem: ^8.0|^9.0|^10.1.3|^11.0
- illuminate/support: ^8.0|^9.0|^10.1.3|^11.0
- smi2/phpclickhouse: ^1.5.3
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.6|^10.5
This package is auto-updated.
Last update: 2024-12-04 21:03:35 UTC
README
Introduction
Laravel ClickHouse database integration. This package includes generation and execution of the ClickHouse database migrations in the Laravel application.
Features
- smi2/phpClickHouse client integration
- Migration creation
- Migration execution
Installation
Pull in the package through Composer.
composer require cybercog/laravel-clickhouse
Setup
Add environment variables in .env
file.
CLICKHOUSE_HOST=localhost CLICKHOUSE_PORT=8123 CLICKHOUSE_USER=default CLICKHOUSE_PASSWORD= CLICKHOUSE_DATABASE=default
Configuration customization
Publish ClickHouse configuration.
php artisan vendor:publish --provider="Cog\Laravel\Clickhouse\ClickhouseServiceProvider" --tag=config
Edit config/clickhouse.php
file.
Usage
ClickHouse client
You can use a singleton object smi2/phpClickHouse to query ClickHouse:
app(\ClickHouseDB\Client::class)->select( /* Query */ ); app(\ClickHouseDB\Client::class)->write( /* Query */ );
ClickHouse database migration
Create migration
php artisan make:clickhouse-migration create_example_table
New migration will be created in
database/clickhouse-migrations
directory.
Run migrations
php artisan clickhouse:migrate
To remove the interactive question during production migrations, you can use --force
option.
php artisan clickhouse:migrate --force
Step
You can specify how many files need to be applied:
php artisan clickhouse:migrate --step=1
Value
0
is default — all files
Rollback migrations
Rolling back migrations is intentionally unavailable. Migrations should go only forward.
Changelog
Detailed changes for each release are documented in the CHANGELOG.md.
License
Laravel ClickHouse
package is open-sourced software licensed under the MIT license by Anton Komarev.
🌟 Stargazers over time
About CyberCog
CyberCog is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion.