dmamontov/clickhouse-migrations-bundle

Symfony ClickhouseMigrationsBundle

Installs: 12 045

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 0

Forks: 4

Type:symfony-bundle

1.0.5 2023-07-10 15:45 UTC

This package is auto-updated.

Last update: 2024-12-10 19:03:05 UTC


README

This bundle added the migrations system for clickhouse type Databases into Symfony applications. Database migrations help you version the changes in your database schema and apply them in a predictable way on every server running the application.

Install

composer require dmamontov/clickhouse-migrations-bundle

Clickhouse connection

For use this bundle you need set clickhouse Client as Symfony service. As example:

#config/services.yaml
services:
    ClickHouseDB\Client:
        arguments:
            $connectParams:
                host: 'http://localhost'
                port: 8123
                username: 'username'
                password: ''
                sslCA: 'path_to_ssl_cert'
            $settings:
                database: 'default'

More details about ClickHouseDB\Client settings.

Settings

If you need set migrations, set clickhouse migrations configuration. But this is not necessary, these settings are set by default:

#config/packages/clickhouse_migrations.yaml
clickhouse_migrations:
    table_name: 'migrations_versions'
    migrations_path: '%kernel.project_dir%/clickhouse_migrations'
    migrations_namespace: 'ClickhouseMigrations'

Using

Generate new migration class:

bin/console clickhouse:migrations:generate

Execute all unapplied migrations up:

bin/console clickhouse:migrations:migrate

One last migration down:

bin/console clickhouse:migrations:migrate down