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.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.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.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.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.AlterIndexTogether

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

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.backends.base.schema.BaseDatabaseSchemaEditor.alter_index_together()

BaseDatabaseSchemaEditor.alter_index_together(model, old_index_together, new_index_together) [source] Changes a model’s index_together value; this will add or remove indexes from the model’s table until they match the new value.

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

BaseDatabaseSchemaEditor.alter_unique_together(model, old_unique_together, new_unique_together) [source] Changes a model’s unique_together value; this will add or remove unique constraints from the model’s table until they match the new value.

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.