Coder Social home page Coder Social logo

laravel-clickhouse-migrations's Introduction

Laravel Clickhouse Migrations

Build Latest Stable Version codecov Total Downloads Downloads Month


Installation

Install this package via Composer.

$ composer require alexeykhr/laravel-clickhouse-migrations

Note: PHP 7.2.5 or later is required

Publish Clickhouse configs:

$ php artisan vendor:publish --provider='Alexeykhr\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

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 Alexeykhr\ClickhouseMigrations\Contracts\MigrationStubHandlerContract interface

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

Path option with Realpath

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 */);

Changelog

Detailed changes for each release are documented in the CHANGELOG.md.

License

MIT

laravel-clickhouse-migrations's People

Contributors

dependabot-preview[bot] avatar oleksiikhr avatar porshe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.