Remove unused functions
This commit is contained in:
parent
f1f0074255
commit
0d94b22b3f
@ -13,6 +13,7 @@ migrations solution.
|
||||
~~**Important: You can only use absolutely import in your `models.py` to make `aerich` work.**~~
|
||||
|
||||
From version `v0.5.0`, there is no such limitation now.
|
||||
|
||||
## Install
|
||||
|
||||
Just install from pypi:
|
||||
@ -111,7 +112,8 @@ Format of migrate filename is
|
||||
`{version_num}_{datetime}_{name|update}.sql`.
|
||||
|
||||
And if `aerich` guess you are renaming a column, it will ask `Rename {old_column} to {new_column} [True]`, you can
|
||||
choice `True` to rename column without column drop, or choice `False` to drop column then create, note that the after maybe lose data.
|
||||
choice `True` to rename column without column drop, or choice `False` to drop column then create, note that the after
|
||||
maybe lose data.
|
||||
|
||||
### Upgrade to latest version
|
||||
|
||||
@ -167,6 +169,8 @@ Now your db rollback to specified version.
|
||||
|
||||
### Inspect db tables to TortoiseORM model
|
||||
|
||||
Currently, only support MySQL.
|
||||
|
||||
```shell
|
||||
Usage: aerich inspectdb [OPTIONS]
|
||||
|
||||
|
@ -5,17 +5,8 @@ from typing import Dict, List, Optional, Tuple, Type
|
||||
|
||||
import click
|
||||
from dictdiffer import diff
|
||||
from tortoise import (
|
||||
BackwardFKRelation,
|
||||
BackwardOneToOneRelation,
|
||||
BaseDBAsyncClient,
|
||||
ForeignKeyFieldInstance,
|
||||
ManyToManyFieldInstance,
|
||||
Model,
|
||||
Tortoise,
|
||||
)
|
||||
from tortoise import BaseDBAsyncClient, Model, Tortoise
|
||||
from tortoise.exceptions import OperationalError
|
||||
from tortoise.fields import Field
|
||||
|
||||
from aerich.ddl import BaseDDL
|
||||
from aerich.models import MAX_VERSION_LENGTH, Aerich
|
||||
@ -358,10 +349,6 @@ class Migrate:
|
||||
if old_model not in new_models.keys():
|
||||
cls._add_operator(cls.remove_model(cls._get_model(old_model)), upgrade)
|
||||
|
||||
@classmethod
|
||||
def _is_fk_m2m(cls, field: Field):
|
||||
return isinstance(field, (ForeignKeyFieldInstance, ManyToManyFieldInstance))
|
||||
|
||||
@classmethod
|
||||
def add_model(cls, model: Type[Model]):
|
||||
return cls.ddl.create_table(model)
|
||||
@ -390,29 +377,6 @@ class Migrate:
|
||||
fields_name = cls._resolve_fk_fields_name(model, fields_name)
|
||||
return cls.ddl.add_index(model, fields_name, unique)
|
||||
|
||||
@classmethod
|
||||
def _exclude_field(cls, field: Field, upgrade=False):
|
||||
"""
|
||||
exclude BackwardFKRelation and repeat m2m field
|
||||
:param field:
|
||||
:return:
|
||||
"""
|
||||
if isinstance(field, ManyToManyFieldInstance):
|
||||
through = field.through
|
||||
if upgrade:
|
||||
if through in cls._upgrade_m2m:
|
||||
return True
|
||||
else:
|
||||
cls._upgrade_m2m.append(through)
|
||||
return False
|
||||
else:
|
||||
if through in cls._downgrade_m2m:
|
||||
return True
|
||||
else:
|
||||
cls._downgrade_m2m.append(through)
|
||||
return False
|
||||
return isinstance(field, (BackwardFKRelation, BackwardOneToOneRelation))
|
||||
|
||||
@classmethod
|
||||
def _add_field(cls, model: Type[Model], field_describe: dict, is_pk: bool = False):
|
||||
return cls.ddl.add_column(model, field_describe, is_pk)
|
||||
|
Loading…
x
Reference in New Issue
Block a user