alexeykhr / laravel-clickhouse-migrations
Laravel 的 Clickhouse 迁移
Requires
- php: ^7.2.5
- illuminate/console: ^7.21
- illuminate/contracts: ^7.21
- illuminate/filesystem: ^7.21
- illuminate/support: ^7.21
- smi2/phpclickhouse: ^1.3
Requires (Dev)
- orchestra/testbench: ^5.3
- dev-master
- v1.0.1
- 1.0.0
- dev-dependabot/composer/dev/league/flysystem-1.1.4
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/dev/smi2/phpclickhouse-1.4.1
- dev-dependabot/composer/dev/laravel/framework-7.30.2
- dev-dependabot/composer/dev/orchestra/testbench-5.9.0
- dev-dependabot/composer/dev/symfony/http-kernel-5.2.0
- dev-dev
This package is auto-updated.
Last update: 2024-09-24 15:52:50 UTC
README
安装
通过 Composer 安装此包。
$ composer require alexeykhr/laravel-clickhouse-migrations
注意:需要 PHP 7.2.5 或更高版本
发布 Clickhouse 配置
$ php artisan vendor:publish --provider='Alexeykhr\ClickhouseMigrations\Providers\MigrationProvider'
基本用法
创建新的迁移文件
$ php artisan make:clickhouse-migration {name}
向上迁移
$ php artisan clickhouse-migrate
回滚最后迁移
$ php artisan clickhouse-migration:rollback
高级用法
新建迁移
要创建新的迁移,使用此命令
$ php artisan make:clickhouse-migration {name}
例如
$ php artisan make:clickhouse-migration create_users_table
新文件将位于配置中指定的路径:clickhouse.path
表
您可以使用库中包含的更准备的占位符,该占位符包含通过添加 --table 选项快速添加新表的模板
$ php artisan make:clickhouse-migration create_users_table --table=users
路径
您可以通过传递 --path 选项来覆盖迁移文件夹的路径
$ php artisan make:clickhouse-migration create_users_table --path=database/new-migrations-folder
如果您想使用文件的绝对路径,请添加一个额外的选项 - 将 --realpath 添加到现有选项中
$ php artisan make:clickhouse-migration create_users_table --path=/path/to/migrations --realpath
占位符
在创建新文件时,您可以使用您的(覆盖)准备好的占位符,列表:clickhouse.stubs
例如
$ php artisan make:clickhouse-migration create_users_table --stub=default
您还可以添加 处理器,使用它们,您可以在每次创建文件时对每个占位符进行自定义
$ php artisan make:clickhouse-migration create_users_table --stub=myStub --stub.handler='App\Clickhouse\MyHandler'
类必须实现
Alexeykhr\ClickhouseMigrations\Contracts\MigrationStubHandlerContract
接口
您可以传递您的 $parameters
,例如
$ php artisan make:clickhouse-migration create_users_table --stub.handler='App\Clickhouse\MyHandler' --stub.param=key:value --stub.param=table:products
您还可以注册一个全局处理器,该处理器将应用于所有生成的占位符文件:clickhouse.handlers.global
向上迁移
强制
为了在生产迁移期间移除交互式问题,您可以使用 --force 选项
$ php artisan clickhouse-migrate --force
输出
使用 --output 选项输出要应用的迁移
$ php artisan clickhouse-migrate --output
在应用显示的迁移之前 - 将显示一个交互式问题,要移除它,请为此选项添加另一个 --force 选项
$ php artisan clickhouse-migrate --output --force
步骤
您可以指定需要应用多少个文件
$ php artisan clickhouse-migrate --step=1
值
0
- 所有文件
向下迁移
与 向上迁移 中具有相同的属性。
其他
您可以使用单例对象 smi2/phpClickHouse 来查询 ClickHouse(用于迁移)
app('clickhouse')->select(/* Query */); app('clickhouse')->write(/* Query */);
变更日志
每个版本的详细更改记录在 CHANGELOG.md 中。