overherz/clickhouse-migrations

为 laravel/lumen 提供的 Clickhouse 迁移工具

1.0.4 2020-06-10 14:11 UTC

This package is auto-updated.

Last update: 2024-09-11 00:00:12 UTC


README

ClickHouse 是一个开源的列式数据库管理系统,能够使用 SQL 查询实时生成分析数据报告。该库适用于 Laravel。

安装

composer require serkarn/laravel-clickhouse-migrations

使用方法

配置 /config/database.php

clickhouse 和迁移设置的示例

...
'clickhouse' => [
    'host' => env('CLICKHOUSE_HOST', 'localhost'),
    'port' => env('CLICKHOUSE_PORT', 8123),
    'username' => env('CLICKHOUSE_USER', 'default'),
    'password' => env('CLICKHOUSE_PASSWORD', ''),
    'options' => [
        'database' => env('CLICKHOUSE_DATABASE', 'default'),
        'timeout' => 1,
        'connectTimeOut' => 2,
    ],
],
'clickhouse-migrations' => [
    'dir' => env('CLICKHOUSE_MIGRATION_DIR', '/database/clickhouse-migrations/'),
    'table' => env('CLICKHOUSE_MIGRATION_TABLE_NAME', 'migrations'),
],
    ...

注册服务提供者

'providers' => [
    ...
    \Serkarn\ClickhouseMigrations\ClickhouseProvider::class,
    ...
],

使用方法

创建新的迁移

php artisan clickhouse:migration:create {name}

向上迁移

php artisan clickhouse:migrate

向下回滚上一次迁移

php artisan clickhouse:migrate --down

构建工具