adata-team/laravel-clickhouse-migrations
最新稳定版本:v1.0.7
Composer 安装命令:
composer require adata-team/laravel-clickhouse-migrations
包简介
Clickhouse migrations for Laravel
README 文档
README
Installation
Install this package via Composer.
composer require adata-team/laravel-clickhouse-migrations
Publish Clickhouse configs:
php artisan vendor:publish --provider='Adata\ClickhouseMigrations\Providers\MigrationProvider'
Basic Usage
Create a new migration file:
php artisan make:clickhouse-migration {name}
Up migrations:
php artisan clickhouse-migrate
Down last migration:
php artisan clickhouse-migration:rollback
Advanced Usage
New Migration
To create a new migration, use this command:
php artisan make:clickhouse-migration {name}
For example:
php artisan make:clickhouse-migration create_users_table
The new file will be located at the path specified in the configs: clickhouse.path
Table
You can use a more prepared stub from the library that contains a template for quickly adding a new table by adding the --table option:
php artisan make:clickhouse-migration create_users_table --table=users
Dictionary
You can use a more prepared stub from the library that contains a template for quickly adding a new table by adding the --table option:
php artisan make:clickhouse-migration create_users_dictionary --dictionary=users
Path
You can override the path to the migrations folder by passing the --path option:
php artisan make:clickhouse-migration create_users_table --path=database/new-migrations-folder
If you want to use an absolute path to the file, add one more option - --realpath to the existing option:
php artisan make:clickhouse-migration create_users_table --path=/path/to/migrations --realpath
Stub
You can use your (override) prepared stub when creating a new file, list: clickhouse.stubs:
For example:
php artisan make:clickhouse-migration create_users_table --stub=default
Also you can add Handlers, with them, you can customize over one stub every time you create a file:
php artisan make:clickhouse-migration create_users_table --stub=myStub --stub.handler='App\Clickhouse\MyHandler'
The class must implement the
Adata\ClickhouseMigrations\Contracts\MigrationStubHandlerContractinterface
You can pass your $parameters, for example:
php artisan make:clickhouse-migration create_users_table --stub.handler='App\Clickhouse\MyHandler' --stub.param=key:value --stub.param=table:products
You can also register a global handler that will apply to all generated stub files: clickhouse.handlers.global
Up Migrations
Force
To remove the interactive question during production migrations, you can use --force option:
php artisan clickhouse-migrate --force
Output
To output migrations to be applied use --output option:
php artisan clickhouse-migrate --output
Before applying the shown migrations - will display an interactive question, to remove it, you can add another --force option to this option:
php artisan clickhouse-migrate --output --force
Step
You can specify how many files need to be applied:
php artisan clickhouse-migrate --step=1
Value
0- all files
Down Migrations
Has the same properties as in Up Migrations.
Other
You can use a singleton object smi2/phpClickHouse to query ClickHouse (used in migrations):
app('clickhouse')->select(/* Query */); app('clickhouse')->write(/* Query */);
License
统计信息
- 总下载量: 1.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-13