mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 16:27:09 +08:00
Improve stubs for contrib.postgres.operations. (#1071)
* Improve stubs for contrib.postgres.operations.
This adds a bunch of missing operations in contrib.postgres.operations.
Documentation: https://docs.djangoproject.com/en/4.0/ref/contrib/postgres/operations/#managing-collations-using-migrations
Source code: 2fac0a1808/django/contrib/postgres/operations.py
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
* Add migration_name_fragment to Operation.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
* Remove redefinition of methods in subclasses.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
|
from typing import Dict, Literal, Tuple
|
||||||
|
|
||||||
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
|
from django.db.migrations import AddConstraint, AddIndex, RemoveIndex
|
||||||
from django.db.migrations.operations.base import Operation
|
from django.db.migrations.operations.base import Operation
|
||||||
|
|
||||||
class CreateExtension(Operation):
|
class CreateExtension(Operation):
|
||||||
reversible: bool = ...
|
reversible: bool = ...
|
||||||
name: str = ...
|
name: str = ...
|
||||||
def __init__(self, name: str) -> None: ...
|
def __init__(self, name: str) -> None: ...
|
||||||
|
def extension_exists(self, schema_editor: BaseDatabaseSchemaEditor, extension: str) -> bool: ...
|
||||||
|
|
||||||
|
class BloomExtension(CreateExtension):
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
class BtreeGinExtension(CreateExtension):
|
class BtreeGinExtension(CreateExtension):
|
||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
@@ -25,3 +33,30 @@ class TrigramExtension(CreateExtension):
|
|||||||
|
|
||||||
class UnaccentExtension(CreateExtension):
|
class UnaccentExtension(CreateExtension):
|
||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
class NotInTransactionMixin:
|
||||||
|
def _ensure_not_in_transaction(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
|
||||||
|
|
||||||
|
class AddIndexConcurrently(NotInTransactionMixin, AddIndex):
|
||||||
|
atomic: Literal[False] = ...
|
||||||
|
|
||||||
|
class RemoveIndexConcurrently(NotInTransactionMixin, RemoveIndex):
|
||||||
|
atomic: Literal[False] = ...
|
||||||
|
|
||||||
|
class CollationOperation(Operation):
|
||||||
|
name: str
|
||||||
|
locale: str
|
||||||
|
provider: str
|
||||||
|
deterministic: bool
|
||||||
|
def __init__(self, name: str, locale: str, *, provider: str = ..., deterministic: bool = ...) -> None: ...
|
||||||
|
def create_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
|
||||||
|
def remove_collation(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
|
||||||
|
|
||||||
|
class CreateCollation(CollationOperation): ...
|
||||||
|
class RemoveCollation(CollationOperation): ...
|
||||||
|
class AddConstraintNotValid(AddConstraint): ...
|
||||||
|
|
||||||
|
class ValidateConstraint(Operation):
|
||||||
|
model_name: str
|
||||||
|
name: str
|
||||||
|
def __init__(self, model_name: str, name: str) -> None: ...
|
||||||
|
|||||||
@@ -25,3 +25,5 @@ class Operation:
|
|||||||
def references_field(self, model_name: str, name: str, app_label: str) -> bool: ...
|
def references_field(self, model_name: str, name: str, app_label: str) -> bool: ...
|
||||||
def allow_migrate_model(self, connection_alias: Union[BaseDatabaseWrapper, str], model: Type[Model]) -> bool: ...
|
def allow_migrate_model(self, connection_alias: Union[BaseDatabaseWrapper, str], model: Type[Model]) -> bool: ...
|
||||||
def reduce(self, operation: Operation, app_label: str) -> Union[bool, List[Operation]]: ...
|
def reduce(self, operation: Operation, app_label: str) -> Union[bool, List[Operation]]: ...
|
||||||
|
@property
|
||||||
|
def migration_name_fragment(self) -> str: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user