django_evolution.db.mysql
Evolution operations backend for MySQL/MariaDB.
Classes
|
Evolution operations for MySQL and MariaDB databases. |
- class django_evolution.db.mysql.EvolutionOperations(database_state, connection=<django.utils.connection.ConnectionProxy object>)
Bases:
BaseEvolutionOperationsEvolution operations for MySQL and MariaDB databases.
- name = 'MySQL / MariaDB'
The name of the database type.
Added in version 2.3.
- get_field_type_allows_default(field)
Return whether default values are allowed for a field.
Added in version 2.2.
- Parameters:
field (
django.db.models.Field) – The field to check.- Returns:
Trueif default values are allowed.Falseif they’re not.- Return type:
- get_change_column_type_sql(model, old_field, new_field)
Return SQL to change the type of a column.
Added in version 2.2.
- Parameters:
model (
type) – The type of model owning the field.old_field (
django.db.models.Field) – The old field.new_field (
django.db.models.Field) – The new field.
- Returns:
The SQL statements for changing the column type.
- Return type:
django_evolution.sql_result.AlterTableSQLResult
- delete_column(model, f)
- rename_column(model, old_field, new_field)
Rename the specified column.
This will rename the column through
ALTER TABLE .. CHANGE COLUMN.Any constraints on the column will be stashed away before the
ALTER TABLEand restored afterward.If the column has not actually changed, or it’s not a real column (a many-to-many relation), then this will return empty statements.
- Parameters:
model (
type) – The model representing the table containing the column.old_field (
django.db.models.Field) – The old field definition.new_field (
django.db.models.Field) – The new field definition.
- Returns:
The statements for renaming the column. This may be an empty list if the column won’t be renamed.
- Return type:
- set_field_null(model, field, null)
- change_column_attr_max_length(model, mutation, field, old_value, new_value)
Returns the SQL for changing a column’s max length.
- get_drop_index_sql(model, index_name)
Returns the database-specific SQL to drop an index.
This can be overridden by subclasses if they use a syntax other than “DROP INDEX <name>;”
- get_change_unique_sql(model, field, new_unique_value, constraint_name, initial)
Returns the database-specific SQL to change a column’s unique flag.
This can be overridden by subclasses if they use a different syntax.
- get_rename_table_sql(model, old_db_table, new_db_table)
Return SQL for renaming a table.
- Parameters:
model (
django.db.models.Model) – The model representing the table to rename.old_db_table (
unicode) – The old table name.new_db_table (
unicode) – The new table name.
- Returns:
The resulting SQL for renaming the table.
- Return type:
- get_default_index_name(table_name, field)
Return a default index name for the database.
This will return an index name for the given field that matches what the database or Django database backend would automatically generate when marking a field as indexed or unique.
This can be overridden by subclasses if the database or Django database backend provides different values.
- Parameters:
table_name (
str) – The name of the table for the index.field (
django.db.models.Field) – The field for the index.
- Returns:
The name of the index.
- Return type:
- get_indexes_for_table(table_name)
Return all known indexes on a table.
This is a fallback used only on Django 1.6, due to lack of proper introspection on that release.
- __annotations__ = {}