ValidateConstraint
Validate a table NOT VALID constraint.
Attributes
| Attribute | Type | Description |
|---|---|---|
| category | [OperationCategory](../../../db/migrations/operations/base/operationcategory.md?sid=django_db_migrations_operations_base_operationcategory) = OperationCategory.ALTERATION | The classification of the operation, identifying it as an alteration to the database schema. |
Constructor
Signature
def ValidateConstraint(
model_name: string,
name: string
)
Parameters
| Name | Type | Description |
|---|---|---|
| model_name | string | The name of the model associated with the constraint. |
| name | string | The name of the constraint to be validated. |
Signature
def ValidateConstraint(
model_name: string,
name: string
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| model_name | string | The name of the model that the constraint belongs to |
| name | string | The specific name of the constraint to be validated |
Methods
describe()
@classmethod
def describe() - > string
Returns a human-readable string describing the constraint validation operation for use in console output.
Returns
| Type | Description |
|---|---|
string | A formatted string indicating the constraint name and the target model |
database_forwards()
@classmethod
def database_forwards(
app_label: string,
schema_editor: [BaseDatabaseSchemaEditor](../../../db/backends/base/schema/basedatabaseschemaeditor.md?sid=django_db_backends_base_schema_basedatabaseschemaeditor),
from_state: [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate),
to_state: [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate)
) - > null
Executes the SQL command to validate the existing constraint on the database table.
Parameters
| Name | Type | Description |
|---|---|---|
| app_label | string | The label of the application the migration belongs to |
| schema_editor | [BaseDatabaseSchemaEditor](../../../db/backends/base/schema/basedatabaseschemaeditor.md?sid=django_db_backends_base_schema_basedatabaseschemaeditor) | The database abstraction layer used to execute SQL statements |
| from_state | [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate) | The state of the project before the operation is applied |
| to_state | [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate) | The state of the project after the operation is applied |
Returns
| Type | Description |
|---|---|
null | None |
database_backwards()
@classmethod
def database_backwards(
app_label: string,
schema_editor: [BaseDatabaseSchemaEditor](../../../db/backends/base/schema/basedatabaseschemaeditor.md?sid=django_db_backends_base_schema_basedatabaseschemaeditor),
from_state: [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate),
to_state: [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate)
) - > null
Performs no action as PostgreSQL does not support reverting a constraint to an invalid state.
Parameters
| Name | Type | Description |
|---|---|---|
| app_label | string | The label of the application the migration belongs to |
| schema_editor | [BaseDatabaseSchemaEditor](../../../db/backends/base/schema/basedatabaseschemaeditor.md?sid=django_db_backends_base_schema_basedatabaseschemaeditor) | The database abstraction layer used to execute SQL statements |
| from_state | [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate) | The state of the project before the operation is applied |
| to_state | [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate) | The state of the project after the operation is applied |
Returns
| Type | Description |
|---|---|
null | None |
state_forwards()
@classmethod
def state_forwards(
app_label: string,
state: [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate)
) - > null
Updates the project state to reflect the operation; however, validation does not change the schema state.
Parameters
| Name | Type | Description |
|---|---|---|
| app_label | string | The label of the application the migration belongs to |
| state | [ProjectState](../../../db/migrations/state/projectstate.md?sid=django_db_migrations_state_projectstate) | The current mutable state of the project to be updated |
Returns
| Type | Description |
|---|---|
null | None |
migration_name_fragment()
@classmethod
def migration_name_fragment() - > string
Generates a string fragment used to name the migration file containing this operation.
Returns
| Type | Description |
|---|---|
string | A slugified string combining the model name and the constraint name |
deconstruct()
@classmethod
def deconstruct() - > tuple
Returns the serialized form of the operation for migration file generation.
Returns
| Type | Description |
|---|---|
tuple | A 3-tuple containing the class name, positional arguments, and keyword arguments |