title: Unable to migrate using ModelState and ProjectState using of migrations API in Django 3.0.3
body: <p>I am using ProjectState to migrate to a new attributes of a table. I am trying to understand the ModelState and ProjectState using of migrations API in Django 3.0.3.</p>
  <p>I am unable to migrate to the new state which has new fields. Can someone help me with the <code>ProjectState</code> and <code>ModelState</code> usage of what to apply for new model_definition migration to work? The following code does not migrate to DB but doesnt give any error.</p>
  <p>I want to migrate from a DB table state to another state and there are some metadata <code>_meta</code>.</p>
  <ul>
  <li><p>The current DB state <code>model_state.fields</code> is:</p>
  <p><code>[('id', &lt;django.db.models.fields.AutoField&gt;)]</code></p>
  </li>
  <li><p>The future DB state <code>model_state.fields</code> after adding <code>fields_attrs</code> migrations should be this using the <code>models_definition</code>:</p>
  <p><code>[('id', &lt;django.db.models.fields.AutoField&gt;), ('name', &lt;django.db.models.fields.CharField&gt;)]</code></p>
  </li>
  </ul>
  <p>Model Definition Code is:</p>
  <p>model_config object is</p>
  <pre><code>{
   '__module__': 'testmodule', 'app_label': 'testmodule', 
   '__unicode__': &lt;function ModelScript.model_create_config.&lt;locals&gt;.&lt;lambda&gt; at 0x00000221B6FBEF70&gt;, 
   'attrs': {'name': &lt;django.db.models.fields.CharField&gt;}
  }
  </code></pre>
  <p>model_definition is:</p>
  <pre><code>model_definition = type(
                  model_item.table_name,
                  # TODO: Put this into Database
                  # model_config.get(&quot;extends&quot;),
                  bases,
                  model_config
              )
  </code></pre>
  <p>This is the code I am using:</p>
  <pre><code>from django.db.migrations.state import ProjectState
  from django.db.migrations.migration import Migration
  from django.db.migrations.state import ModelState
  from django.db.migrations import operations
  
  # model_definition is coming from a function as the following object
  model_definition = {'__module__': 'testmodule', 'app_label': 'testmodule', '__unicode__': &lt;function ModelScript.model_create_config.&lt;locals&gt;.&lt;lambda&gt; at 0x000002047275FF70&gt;, 'attrs': {'name': &lt;django.db.models.fields.CharField&gt;}, '__doc__': 'SampleModel(id)', '_meta': &lt;Options for SampleModel&gt;, 'DoesNotExist': &lt;class 'testmodule.SampleModel.DoesNotExist'&gt;, 'MultipleObjectsReturned': &lt;class 'testmodule.SampleModel.MultipleObjectsReturned'&gt;, 'id': &lt;django.db.models.query_utils.DeferredAttribute object at 0x00000204727F9430&gt;, 'objects': &lt;django.db.models.manager.ManagerDescriptor object at 0x00000204727F9490&gt;}
  
  model_state = ModelState.from_model(model_definition)
  
  # field_attrs are all the new fields to be migrated         
  for k,v in field_attrs.items():
      model_state.fields.append((k, v))
  
  # Create a fake migration with the CreateModel operation
  cm = operations.CreateModel(name=model_state.name, fields=model_state.fields)
  
  migration = Migration(&quot;fake_migration&quot;, model_state.app_label)
  migration.operations.append(cm)
  
  # SHOULD ProjectState be used for the new definition to be APPLIED to DB and HOW?
  state = ProjectState()
  with db_conn.schema_editor(collect_sql=True, atomic=migration.atomic) as schema_editor:
       # Following create_model also doesnot migrate to Mysql DB
       # Gives a Table exists Error even with root user of mysql
       # schema_editor.create_model(model_definition)
  
       # Following doesnot migrate to the new required state
       state = migration.apply(state, schema_editor, collect_sql=True)
       # Following gives atomic transaction error if used along with atomic
       # following commit commented gives no error but doesnt migrate
       # db_conn.commit()
  </code></pre>
  <p>I have read this and using <a href="https://stackoverflow.com/questions/48666334/how-to-programmatically-generate-the-create-table-sql-statement-for-a-given-mode">How to programmatically generate the CREATE TABLE SQL statement for a given model in Django?</a></p>
  <p>Any help or resource is welcome on this.</p>
  <p>Update: I did try the test cases of Django and it didn't work programmatically. Do I have to use addfield categorically? Unsure of how to get this working. Both projectstate and model_create way is not working</p>