Module: Cassie::Schema

Extended by:
Configuration, Versioning
Defined in:
lib/cassie/schema.rb,
lib/cassie/schema/queries.rb,
lib/cassie/schema/version.rb,
lib/cassie/schema/migrator.rb,
lib/cassie/schema/migration.rb,
lib/cassie/schema/versioning.rb,
lib/cassie/schema/apply_command.rb,
lib/cassie/schema/configuration.rb,
lib/cassie/schema/migration/dsl.rb,
lib/cassie/schema/version_loader.rb,
lib/cassie/schema/version_writer.rb,
lib/cassie/schema/rollback_command.rb,
lib/cassie/schema/structure_dumper.rb,
lib/cassie/schema/structure_loader.rb,
lib/cassie/schema/version_file_loader.rb,
lib/cassie/schema/version_object_loader.rb,
lib/cassie/schema/migration/cassandra_support.rb,
lib/cassie/schema/queries/drop_keyspace_query.rb,
lib/cassie/schema/queries/delete_version_query.rb,
lib/cassie/schema/queries/insert_version_query.rb,
lib/cassie/schema/cassandra_migrations/importer.rb,
lib/cassie/schema/queries/create_keyspace_query.rb,
lib/cassie/schema/queries/select_versions_query.rb,
lib/cassie/schema/cassandra_migrations/migration_file.rb,
lib/cassie/schema/queries/create_versions_table_query.rb

Overview

Contains interface and components for managing Cassandra schema using semantically versioned, incremental migration files.

  • Versioned migration files are stored in-repo in ruby files defining up and down mutation methods.

  • Data about what migrations have been applied is stored in Cassandra persistence.

  • The schema state is stored in an in-repo schema file that contains the CQL required to recreate the current schema state/version from scratch.

  • Various cassie executable commands provide an interface to manage migrations and versioning.

Run cassie –help to see a list of commands and their descriptions for managing the schema through versioned migrations.

Defined Under Namespace

Modules: CassandraMigrations, Configuration, Queries, Versioning Classes: AlreadyInitiailizedError, ApplyCommand, CreateKeyspaceQuery, CreateVersionsTableQuery, DeleteVersionQuery, DropKeyspaceQuery, InsertVersionQuery, Migration, Migrator, RollbackCommand, SelectVersionsQuery, StructureDumper, StructureLoader, UninitializedError, Version, VersionFileLoader, VersionLoader, VersionObjectLoader, VersionWriter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#schema_keyspaceObject Originally defined in module Configuration

The keyspace in which to store Cassie schema data

#versions_tableObject Originally defined in module Configuration

The table in which to store Cassie schema applied versions data

Class Method Details

.applied_versionsEnumerable<Version> Originally defined in module Versioning

The versions that have been migrated up for the Cassandra database This lists the versions stored in the persistence layer, in reverse chronological order (newest first).

Returns:

.forget_version(version) ⇒ Boolean Originally defined in module Versioning

Remove the version from the schema version store. This should only be done if the version has been sucesfully reverted

Parameters:

  • version (Version)

    A persisted version

Returns:

  • (Boolean)

    whether succesfull or not

.initialize_versioningvoid Originally defined in module Versioning

This method returns an undefined value.

Create the keyspace and table for tracking schema versions in the Cassandra database

.local_versionsEnumeration<Version> Originally defined in module Versioning

Versions for the #migration_files If a migration is applied versions, the object for that version will be the applied version, containing the full information about the applied version

Returns:

.migration_filesArray<String> Originally defined in module Versioning

Absolute paths to the migration files in the migration directory

Returns:

  • (Array<String>)

.next_version(bump_type = nil) ⇒ Version Originally defined in module Versioning

A version with an incremented version number that would be applied after the latest (local or applied) migration.

Parameters:

  • bump_type (Symbol, nil) (defaults to: nil)

    Which semantic version to bump

Options Hash (bump_type):

  • :build (Symbol)

    Bump the build version

  • :patch (Symbol)

    Bump the patch version, set build to 0

  • :minor (Symbol)

    Bump the minor version, set patch and build to 0

  • :major (Symbol)

    Bump the major version, set minor, patch, and build to 0

  • nil (nil)

    Default, bumps patch, sets build to 0

Returns:

  • (Version)

    The initialized, bumped version

.pathsHash Originally defined in module Configuration

Paths used for configuration loading.

Returns:

  • (Hash)
    • :schema_file - The .cql file defining the current schema structure

    • :migrations_directory - The directory containing the versioned schema migration .rb files

.record_version(version, set_execution_metadata = true) ⇒ Boolean Originally defined in module Versioning

Record a version in the schema version store. This should only be done if the version has been sucesfully migrated

Parameters:

  • The (Version)

    version to record

  • set_execution_metadata (Boolean) (defaults to: true)

    Determines whether or not to populate the version object with execution tracking info (id, executed_at, and executor).

Returns:

  • (Boolean)

    whether succesfull or not

.versionVersion Originally defined in module Versioning

The current schema version

Returns: