Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

8/7/2018

Reading time:1 min

rackerlabs/cdeploy

by John Doe

cdeploy is a simple tool to manage your Cassandra schema migrations in the style of dbdeploypip install cdeployBy default, cdeploy will look for migrations in './migrations'. This can be overridden by passing the path to your migrations directory as the first argument:cdeploy db/migrationsThe migrations directory should contain CQL scripts using the following naming convention: [version]_migration_description.cqlFor example:migrations/ 001_create_orders_table.cql 002_create_customers_table.cqlVersion numbers should begin from 1. Migration scripts may contain multiple semicolon terminated CQL statements. Comment lines can begin with either "--" or "//".Migrations can also specify how to revert the changes by including additional statements following a line containing "--//@UNDO". For example:CREATE TABLE orders( order_id uuid PRIMARY KEY, price text);--//@UNDODROP TABLE orders;To undo the most recently applied migration, run:cdeploy --undo from cdeploy import migrator schema_migrator = migrator.Migrator('/path/to/migrations/directory', cassandra_session) schema_migrator.run_migrations()cdeploy will look in your migrations directory for a configuration file named cassandra.yml, in a subdirectory named config:migrations/ config/ cassandra.ymlThe configuration file specifies the hosts to connect to and the keyspace name, and supports multiple environments. For example:development: hosts: [host1] keyspace: keyspace_nameproduction: hosts: [host1, host2, host3] keyspace: keyspace_nameThe environment can be set via the ENV shell variable, and defaults to development if not specified:ENV=production cdeployAdditional configuration parameters for Cassandra are available:development: hosts: [host1] keyspace: keyspace_name auth_enabled: true auth_username: username auth_password: password port: 9042 ssl_enabled: true ssl_ca_certs: /path/to/ca/certs consistency_level: ALL timeout: 10

Illustration Image

cdeploy is a simple tool to manage your Cassandra schema migrations in the style of dbdeploy

pip install cdeploy

By default, cdeploy will look for migrations in './migrations'. This can be overridden by passing the path to your migrations directory as the first argument:

cdeploy db/migrations

The migrations directory should contain CQL scripts using the following naming convention: [version]_migration_description.cql

For example:

migrations/
    001_create_orders_table.cql
    002_create_customers_table.cql

Version numbers should begin from 1. Migration scripts may contain multiple semicolon terminated CQL statements. Comment lines can begin with either "--" or "//".

Migrations can also specify how to revert the changes by including additional statements following a line containing "--//@UNDO". For example:

CREATE TABLE orders(
    order_id uuid PRIMARY KEY,
    price text
);
--//@UNDO
DROP TABLE orders;

To undo the most recently applied migration, run:

cdeploy --undo
    from cdeploy import migrator
    schema_migrator = migrator.Migrator('/path/to/migrations/directory', cassandra_session)
    schema_migrator.run_migrations()

cdeploy will look in your migrations directory for a configuration file named cassandra.yml, in a subdirectory named config:

migrations/
   config/
       cassandra.yml

The configuration file specifies the hosts to connect to and the keyspace name, and supports multiple environments. For example:

development:
    hosts: [host1]
    keyspace: keyspace_name
production:
    hosts: [host1, host2, host3]
    keyspace: keyspace_name

The environment can be set via the ENV shell variable, and defaults to development if not specified:

ENV=production cdeploy

Additional configuration parameters for Cassandra are available:

development:
    hosts: [host1]
    keyspace: keyspace_name
    auth_enabled: true
    auth_username: username
    auth_password: password
    port: 9042
    ssl_enabled: true
    ssl_ca_certs: /path/to/ca/certs
    consistency_level: ALL
    timeout: 10

Related Articles

cluster
troubleshooting
datastax

GitHub - arodrime/Montecristo: Datastax Cluster Health Check Tooling

arodrime

4/3/2024

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra