db.migrations.operations.AlterIndexTogether

class AlterIndexTogether(name, index_together) [source] Changes the model’s set of custom indexes (the index_together option on the Meta subclass).

db.migrations.operations.AlterField

class AlterField(model_name, name, field, preserve_default=True) [source] Alters a field’s definition, including changes to its type, null, unique, db_column and other field attributes. The preserve_default argument indicates whether the field’s default value is permanent and should be baked into the project state (True), or if it is temporary and just for this migration (False) - usually because the migration is altering a nullable field to a non-nullable one and needs a default value to pu

db.migrations.operations.AddField

class AddField(model_name, name, field, preserve_default=True) [source] Adds a field to a model. model_name is the model’s name, name is the field’s name, and field is an unbound Field instance (the thing you would put in the field declaration in models.py - for example, models.IntegerField(null=True). The preserve_default argument indicates whether the field’s default value is permanent and should be baked into the project state (True), or if it is temporary and just for this migration (Fal

db.migrations.Migration.initial

Migration.initial New in Django 1.9. The “initial migrations” for an app are the migrations that create the first version of that app’s tables. Usually an app will have just one initial migration, but in some cases of complex model interdependencies it may have two or more. Initial migrations are marked with an initial = True class attribute on the migration class. If an initial class attribute isn’t found, a migration will be considered “initial” if it is the first migration in the app (i

db.connection.creation.destroy_test_db()

destroy_test_db(old_database_name, verbosity=1, keepdb=False) Destroys the database whose name is the value of NAME in DATABASES, and sets NAME to the value of old_database_name. The verbosity argument has the same behavior as for DiscoverRunner. If the keepdb argument is True, then the connection to the database will be closed, but the database will not be destroyed.

db.connection.creation.create_test_db()

create_test_db(verbosity=1, autoclobber=False, serialize=True, keepdb=False) Creates a new test database and runs migrate against it. verbosity has the same behavior as in run_tests(). autoclobber describes the behavior that will occur if a database with the same name as the test database is discovered: If autoclobber is False, the user will be asked to approve destroying the existing database. sys.exit is called if the user does not approve. If autoclobber is True, the database will be dest

db.backends.base.schema.SchemaEditor.connection

SchemaEditor.connection A connection object to the database. A useful attribute of the connection is alias which can be used to determine the name of the database being accessed. This is useful when doing data migrations for migrations with multiple databases.

db.backends.base.schema.BaseDatabaseSchemaEditor.remove_field()

BaseDatabaseSchemaEditor.remove_field(model, field) [source] Removes the column(s) representing the field from the model’s table, along with any unique constraints, foreign key constraints, or indexes caused by that field. If the field is a ManyToManyField without a value for through, it will remove the table created to track the relationship. If through is provided, it is a no-op.

db.backends.base.schema.BaseDatabaseSchemaEditor.execute()

BaseDatabaseSchemaEditor.execute(sql, params=[]) [source] Executes the SQL statement passed in, with parameters if supplied. This is a simple wrapper around the normal database cursors that allows capture of the SQL to a .sql file if the user wishes.

db.backends.base.schema.BaseDatabaseSchemaEditor.delete_model()

BaseDatabaseSchemaEditor.delete_model(model) [source] Drops the model’s table in the database along with any unique constraints or indexes it has.