Class SchemaTransformations

java.lang.Object
org.apache.cassandra.schema.SchemaTransformations

public class SchemaTransformations extends Object
Factory and utility methods to create simple schema transformation.
  • Constructor Details

    • SchemaTransformations

      public SchemaTransformations()
  • Method Details

    • addKeyspace

      public static SchemaTransformation addKeyspace(KeyspaceMetadata keyspace, boolean ignoreIfExists)
      Creates a schema transformation that adds the provided keyspace.
      Parameters:
      keyspace - the keyspace to add.
      ignoreIfExists - if true, the transformation is a no-op if a keyspace of the same name than keyspace already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException in that case.
      Returns:
      the created transformation.
    • addTable

      public static SchemaTransformation addTable(TableMetadata table, boolean ignoreIfExists)
      Creates a schema transformation that adds the provided table.
      Parameters:
      table - the table to add.
      ignoreIfExists - if true, the transformation is a no-op if a table of the same name than table already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException in that case.
      Returns:
      the created transformation.
    • addTypes

      public static SchemaTransformation addTypes(Types toAdd, boolean ignoreIfExists)
    • addView

      public static SchemaTransformation addView(ViewMetadata view, boolean ignoreIfExists)
      Creates a schema transformation that adds the provided view.
      Parameters:
      view - the view to add.
      ignoreIfExists - if true, the transformation is a no-op if a view of the same name than view already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException in that case.
      Returns:
      the created transformation.
    • updateSystemKeyspace

      public static SchemaTransformation updateSystemKeyspace(KeyspaceMetadata keyspace, long generation)
      We have a set of non-local, distributed system keyspaces, e.g. system_traces, system_auth, etc. (see SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES), that need to be created on cluster initialisation, and later evolved on major upgrades (sometimes minor too). This method compares the current known definitions of the tables (if the keyspace exists) to the expected, most modern ones expected by the running version of C*. If any changes have been detected, a schema transformation returned by this method should make cluster's view of that keyspace aligned with the expected modern definition.
      Parameters:
      keyspace - the metadata of the keyspace as it should be after application.
      generation - timestamp to use for the table changes in the schema mutation
      Returns:
      the transformation.