{"id":18832679,"url":"https://github.com/datto/cass_schema","last_synced_at":"2025-10-18T12:19:06.606Z","repository":{"id":79939791,"uuid":"48003697","full_name":"datto/cass_schema","owner":"datto","description":"A gem for managing multiple Cassandra schemas across multiple clusters.","archived":false,"fork":false,"pushed_at":"2015-12-14T22:02:58.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-30T07:21:38.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-14T22:01:32.000Z","updated_at":"2024-11-28T16:32:02.000Z","dependencies_parsed_at":"2023-03-12T09:29:29.038Z","dependency_job_id":null,"html_url":"https://github.com/datto/cass_schema","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datto%2Fcass_schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datto%2Fcass_schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datto%2Fcass_schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datto%2Fcass_schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datto","download_url":"https://codeload.github.com/datto/cass_schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239768927,"owners_count":19693763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T01:58:43.328Z","updated_at":"2025-10-18T12:19:06.490Z","avatar_url":"https://github.com/datto.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CassSchema\n\nA gem for managing multiple cassandra schemas across multiple clusters. CassSchema supports loading a table schema from scratch, as well as running a migration to apply a change to the schema. Unlike some other database migration tools, there is no stored state about which migrations have and have not been run -- a migration is simply a CQL statement to be run against the database.\n\nCassSchema operations apply to multiple 'datastores'. A datastore is a cluster, keyspace pair, so there may be multiple schemas for a single cluster, but only a single schema for a given cluster plus keyspace.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'cass_schema', github: 'backupify/cass_schema'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install cass_schema\n\n## Usage\n\nBefore usage, CassSchema must be initialized with a set of datastore objects, as well as a base directory where the schema definitions live:\n\n```ruby\nCassSchema::Runner.initialize(\n  datastores: CassSchema::YamlHelper.datastores('my/path/to/config.yml'),\n  schema_base_path: 'my/path/to/schema/root')\n```\n\nHere the datastores are a list of `CassSchema::DataStore` objects. These may be build manually, or loaded from a yaml file using the `CassSchema::YamlHelper`. CassSchema is intentionally agnostic about the source of these datastores.\n\nThe schema_base_path is a directory where the schema definitions and migrations live. The structure of this directory should be:\n```\n\u003cschema_base_path\u003e/\u003cdatastore_name\u003e/schema.cql\n\u003cschema_base_path\u003e/\u003cdatastore_name\u003e/migrations/\u003cmigration1\u003e.cql\n\u003cschema_base_path\u003e/\u003cdatastore_name\u003e/migrations/\u003cmigration2\u003e.cql\n...\n\n```\n\nThe contents of each cql file should be a list of CQL statements. Comments starting with '#' are supported, and each statement should be separated by two new lines.\n\nschema.cql and each migration should be maintained by hand. It is recommended that schema.cql contain a complete list of CQL statements for the entire, up-to-date schema.\n\nAn example yml config and datastore schema definition are in the `test/fixtures` directory.\n\n### Rake tasks\n\nThe file `lib/cass_schema/tasks/schema.rake` defines several rake tasks for schema management. In a Rails project, these tasks are loaded when cass_schema is first loaded.\n\n* `rake cass:schema:create_all` - create all schemas\n* `rake cass:schema:drop_all` - drop all schemas\n* `rake cass:schema:create[datastore]` - create the schema for the datastore named 'datastore'\n* `rake cass:schema:drop[datastore]` - drop the schema for the datastore named 'datastore'\n* `rake cass:schema:migrate[datastore, migration]` - run the migration 'migration' for the datastore 'datastore'\n\n### Ruby Library Usage\n\nTo create all datastore schemas:\n\n```\nCassSchema::Runner.create_all\n```\n\nTo create a particular datastore schemas:\n\n```\nCassSchema::Runner.create('datastore')\n```\n\nTo drop all datastore schemas:\n\n```\nCassSchema::Runner.drop_all\n```\n\nTo drop a particular datastore schemas:\n\n```\nCassSchema::Runner.drop('datastore')\n```\n\nTo run a particular migration for a particular datastore:\n\n```\nCassSchema::Runner.migrate('datastore', 'migration')\n```\n\nHere the migration file 'migration.cql' should exist.\n\n### Integration with other libraries\n\nWhile `CassSchema::YamlLoader` provides ease of use, it is not required: the runner can be instantiated\nwith any list of `CassSchema::Datastore` objects. Here is an example manual set up:\n\n```ruby\ncluster = CassSchema::Cluster.build(hosts: ['127.0.0.1'], port: 9242)\nreplication = \"{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }\"\ndatastores = [\n  CassSchema::Datastore.build('test_datastore', cluster: cluster, keyspace: 'test_keyspace', replication: replication),\n  CassSchema::Datastore.build('test_datastore2', cluster: cluster, keyspace: 'test_keyspace2', replication: replication),\n]\nRunner.setup(datastores: datastores, schema_base_path: 'my/base/path')\n```\n\nThis allows CassSchema to be integrated into other configuration schemes more easily.\n\nAdditionally, the global `CassSchema::Runner` object need not be used: An instance of `CassSchema::Runner` can be\nconstructed and used in the same manner as the global object:\n\n```ruby\n# Accepts the same arguments as Runner#setup\nrunner = Runner.new(datastores: datastores, schema_base_path: 'my/base/path')\nrunner.create_all\n```\n\n\n## Contributing\n\n1. Fork it ( https://github.com/backupify/cass_schema/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatto%2Fcass_schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatto%2Fcass_schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatto%2Fcass_schema/lists"}