Skip to main content

ValidateConstraint

Validate a table NOT VALID constraint.

Attributes

AttributeTypeDescription
category[OperationCategory](../../../db/migrations/operations/base/operationcategory.md?sid=django_db_migrations_operations_base_operationcategory) = OperationCategory.ALTERATIONThe classification of the operation, identifying it as an alteration to the database schema.

Constructor

Signature

def ValidateConstraint(
model_name: string,
name: string
)

Parameters

NameTypeDescription
model_namestringThe name of the model associated with the constraint.
namestringThe name of the constraint to be validated.

Signature

def ValidateConstraint(
model_name: string,
name: string
) - > null

Parameters

NameTypeDescription
model_namestringThe name of the model that the constraint belongs to
namestringThe 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

TypeDescription
stringA 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

NameTypeDescription
app_labelstringThe 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

TypeDescription
nullNone

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

NameTypeDescription
app_labelstringThe 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

TypeDescription
nullNone

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

NameTypeDescription
app_labelstringThe 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

TypeDescription
nullNone

migration_name_fragment()

@classmethod
def migration_name_fragment() - > string

Generates a string fragment used to name the migration file containing this operation.

Returns

TypeDescription
stringA 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

TypeDescription
tupleA 3-tuple containing the class name, positional arguments, and keyword arguments