title: A correct way to alter Cassandra table via C#
body: <p>My issue is in the next.</p>
  
  <p>I have the next simple model in my code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Client
  {
      public Guid Id { get; set; }
  
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I defined a mapping for it:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CustomMappings : Mappings
  {
      public CustomMappings()
      {
          For&lt;Client&gt;().TableName("clients")
                       .PartitionKey(x =&gt; x.Id);
      }
  }
  </code></pre>
  
  <p>I created the table via <code>Table&lt;TEntity&gt;.CreateIfNotExist()</code> method:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var table = new Table&lt;Client&gt;(session);
  table.CreateIfNotExists();
  </code></pre>
  
  <p>And I can insert my data by the next way:</p>
  
  <pre class="lang-cs prettyprint-override"><code>IMapper mapper = new Mapper(session);
  
  var client = new Client
  {
      Id = Guid.NewGuid(),
      Name = "John Smith"
  };
  
  await mapper.UpdateAsync(client);
  </code></pre>
  
  <p>After this, I've changed my model by adding a new property:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Client
  {
      public Guid Id { get; set; }
  
      public string Name { get; set; }
  
      public string Surname { get; set; }
  }
  </code></pre>
  
  <p>I need to alter this table, because I want to add surname column to it.
  Of course, I have the exception without it when I try to insert a value:</p>
  
  <pre class="lang-cs prettyprint-override"><code>Cassandra.InvalidQueryException: Undefined column name surname
     at Cassandra.Requests.PrepareHandler.Prepare(PrepareRequest request, IInternalSession session, Dictionary`2 triedHosts)
     at Cassandra.Requests.PrepareHandler.Prepare(IInternalSession session, Serializer serializer, PrepareRequest request)
     at Cassandra.Session.PrepareAsync(String query, IDictionary`2 customPayload)
     at Cassandra.Mapping.Statements.StatementFactory.GetStatementAsync(ISession session, Cql cql, Nullable`1 forceNoPrepare)
     at Cassandra.Mapping.Mapper.ExecuteAsync(Cql cql)
  
  </code></pre>
  
  <p>But class <code>Cassandra.Data.Linq.Table&lt;TEntity&gt;</code> does not contain neither nor <code>.AlterOrCreate()</code> nor <code>.Alter()</code> methods. Also, we don't have <code>.GetAlter()</code> method in <code>Cassandra.Mapping.Statements.CqlGenerator</code>.</p>
  
  <p>Which way is more appropriate to solve this problem? I have two assumptions (besides creating a pull request with needed methods to datastax csharp driver repository on github :)).</p>
  
  <ol>
  <li>To alter tables via cql script in .cql file which will be executed in c# code.</li>
  <li>To create a new table after each changes of a model and migrate old data to it.</li>
  </ol>
  
  <p>I'm a newbee in Cassandra and I have suspicions that needed method does not exist in the library for good reason. Maybe, are there any problems with consistency after altering because Cassandra is distributed database?</p>