django_evolution.db.postgresql
Evolution operations backend for Postgres.
Classes
|
Evolution operations for Postgres databases. |
- class django_evolution.db.postgresql.EvolutionOperations(database_state, connection=<django.db.DefaultConnectionProxy object>)
Bases:
BaseEvolutionOperations
Evolution operations for Postgres databases.
- name = 'Postgres'
The name of the database type.
New in version 2.3.
- default_tablespace = 'pg_default'
The default tablespace for the database, if tablespaces are supported.
New in version 2.2.
- Type:
- change_column_type_sets_attrs = False
Whether a column type change operation also sets new attributes.
If
False
, attributes will be set through the standard field change operation.New in version 2.2.
- Type:
- alter_field_type_map = {'bigserial': 'bigint', 'serial': 'integer', 'smallserial': 'smallint'}
A mapping of field types for use when altering types.
New in version 2.2.
- get_change_column_type_sql(model, old_field, new_field)
Return SQL to change the type of a column.
New 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
- rename_column(model, old_field, new_field)
Renames the specified column.
This must be implemented by subclasses. It must return an SQLResult or AlterTableSQLResult representing the SQL needed to rename the column.
- get_drop_unique_constraint_sql(model, index_name)
- 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.
- normalize_bool(value)
- change_column_attr_decimal_type(model, mutation, field, new_max_digits, new_decimal_places)
Return SQL for changing a column’s max digits and decimal places.
This is used for
DecimalField
and subclasses to change the maximum number of digits or decimal places. As these are used together as a column type, they must be considered together as one attribute change.- Parameters:
model (
type
) – The model class that owns the field.mutation (
django_evolution.mutations.BaseModelMutation
) – The mutation applying this change.field (
django.db.models.DecimalField
) – The field being modified.new_max_digits (
int
) – The new value formax_digits
. IfNone
, it wasn’t provided in the attribute change.new_decimal_places (
int
) – The new value fordecimal_places
. IfNone
, it wasn’t provided in the attribute change.
- Returns:
The SQL for modifying the value.
- Return type: