nechehin / clickhouse-migrations

为laravel/lumen的ClickHouse迁移

0.6.0 2024-06-17 13:22 UTC

README

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

安装

composer require nechehin/laravel-clickhouse-migrations

用法

配置/config/database.php

clickhouse和迁移设置的示例

'connections' => [

    ...

    '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

构建于