o a@sddlmZGdddZdS))routerc@seZdZdZdZdZdZdZgZddZ ddZ dd Z d d Z d d Z ddZeddZddZddZddZddZddZdS) Operationa) Base class for migration operations. It's responsible for both mutating the in-memory model state (see db/migrations/state.py) to represent what it performs, as well as actually performing it against a live database. Note that some operations won't modify memory state at all (e.g. data copying operations), and some will need their modifications to be optionally specified by the user (e.g. custom Python code snippets) Due to the way this class deals with deconstruction, it should be considered immutable. TFcOst|}||f|_|S)N)object__new___constructor_args)clsargskwargsselfr F/usr/lib/python3/dist-packages/django/db/migrations/operations/base.pyr$s  zOperation.__new__cCs|jj|jd|jdfS)z Return a 3-tuple of class import path (or just name if it lives under django.db.migrations), positional arguments, and keyword arguments. r __class____name__rr r r r deconstruct*szOperation.deconstructcCtd)z Take the state from the previous migration, and mutate it so that it matches what this migration would perform. z>subclasses of Operation must provide a state_forwards() methodNotImplementedError)r app_labelstater r r state_forwards6zOperation.state_forwardscCr)zi Perform the mutation on the database schema in the normal (forwards) direction. zAsubclasses of Operation must provide a database_forwards() methodrr r schema_editor from_stateto_stater r r database_forwards=rzOperation.database_forwardscCr)z Perform the mutation on the database schema in the reverse direction - e.g. if this were CreateModel, it would in fact drop the model's table. zBsubclasses of Operation must provide a database_backwards() methodrrr r r database_backwardsDszOperation.database_backwardscCsd|jj|jfS)zA Output a brief summary of what the action does. z%s: %srrr r r describeLszOperation.describecCdS)z A filename part suitable for automatically naming a migration containing this operation, or None if not applicable. Nr rr r r migration_name_fragmentRsz!Operation.migration_name_fragmentcCr!)a Return True if there is a chance this operation references the given model name (as a string), with an app label for accuracy. Used for optimization. If in doubt, return True; returning a false positive will merely make the optimizer a little less efficient, while returning a false negative may result in an unusable optimized migration. Tr )r namerr r r references_modelZs zOperation.references_modelcCs |||S)z Return True if there is a chance this operation references the given field name, with an app label for accuracy. Used for optimization. If in doubt, return True. )r$)r model_namer#rr r r references_fieldfs zOperation.references_fieldcCs|j|sdSt||S)z Return whether or not a model may be migrated. This is a thin wrapper around router.allow_migrate_model() that preemptively rejects any proxy, swapped out, or unmanaged model. F)_meta can_migraterallow_migrate_model)r connection_aliasmodelr r r r)os  zOperation.allow_migrate_modelcCs|jr|gS|jr |gSdS)z Return either a list of operations the actual operation should be replaced with or a boolean that indicates whether or not the specified operation can be optimized across. F)elidable)r operationrr r r reduce{s zOperation.reducecCs>d|jjdtt|jdddd|jdDfS)Nz <%s %s%s>z, r,css|]}d|VqdS)z %s=%rNr ).0xr r r sz%Operation.__repr__..r )rrjoinmapreprritemsrr r r __repr__s zOperation.__repr__N)r __module__ __qualname____doc__ reversiblereduces_to_sqlatomicr,serialization_expand_argsrrrrrr propertyr"r$r&r)r.r7r r r r rs(     rN) django.dbrrr r r r s