Fix rename field on the field add. (#134)

This commit is contained in:
long2ice 2021-03-21 20:43:05 +08:00
parent 505d361597
commit 364735f804
5 changed files with 40 additions and 25 deletions

View File

@ -2,6 +2,10 @@
## 0.5 ## 0.5
### 0.5.2
- Fix rename field on the field add. (#134)
### 0.5.1 ### 0.5.1
- Fix tortoise connections not being closed properly. (#120) - Fix tortoise connections not being closed properly. (#120)

View File

@ -1 +1 @@
__version__ = "0.5.1" __version__ = "0.5.2"

View File

@ -257,14 +257,23 @@ class Migrate:
old_data_field_name = old_data_field.get("name") old_data_field_name = old_data_field.get("name")
if len(changes) == 2: if len(changes) == 2:
# rename field # rename field
if changes[0] == ( if (
"change", changes[0]
"name", == (
(old_data_field_name, new_data_field_name), "change",
) and changes[1] == ( "name",
"change", (old_data_field_name, new_data_field_name),
"db_column", )
(old_data_field.get("db_column"), new_data_field.get("db_column")), and changes[1]
== (
"change",
"db_column",
(
old_data_field.get("db_column"),
new_data_field.get("db_column"),
),
)
and old_data_field_name not in new_data_fields_name
): ):
if upgrade: if upgrade:
is_rename = click.prompt( is_rename = click.prompt(

30
poetry.lock generated
View File

@ -269,7 +269,7 @@ python-versions = "*"
[[package]] [[package]]
name = "isort" name = "isort"
version = "5.7.0" version = "5.8.0"
description = "A Python utility / library to sort Python imports." description = "A Python utility / library to sort Python imports."
category = "dev" category = "dev"
optional = false optional = false
@ -404,12 +404,12 @@ optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]] [[package]]
name = "pypika" name = "pypika-tortoise"
version = "0.44.1" version = "0.1.0"
description = "A SQL query builder API for Python" description = "Forked from pypika and streamline just for tortoise-orm"
category = "main" category = "main"
optional = false optional = false
python-versions = "*" python-versions = ">=3.7,<4.0"
[[package]] [[package]]
name = "pytest" name = "pytest"
@ -552,7 +552,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]] [[package]]
name = "tortoise-orm" name = "tortoise-orm"
version = "0.16.21" version = "0.17.0"
description = "Easy async ORM for python, built with relations in mind" description = "Easy async ORM for python, built with relations in mind"
category = "main" category = "main"
optional = false optional = false
@ -561,12 +561,13 @@ python-versions = ">=3.7,<4.0"
[package.dependencies] [package.dependencies]
aiosqlite = ">=0.16.0,<0.17.0" aiosqlite = ">=0.16.0,<0.17.0"
iso8601 = ">=0.1.13,<0.2.0" iso8601 = ">=0.1.13,<0.2.0"
pypika = ">=0.44.0,<0.45.0" pypika-tortoise = ">=0.1.0,<0.2.0"
pytz = ">=2020.4,<2021.0" pytz = ">=2020.4,<2021.0"
[package.extras] [package.extras]
docs = ["pygments", "cloud-sptheme", "docutils", "sphinx"] docs = ["pygments", "cloud-sptheme", "docutils", "sphinx"]
aiomysql = ["aiomysql"] aiomysql = ["aiomysql"]
asyncmy = ["asyncmy"]
asyncpg = ["asyncpg"] asyncpg = ["asyncpg"]
accel = ["ciso8601 (>=2.1.2,<3.0.0)", "python-rapidjson", "uvloop (>=0.14.0,<0.15.0)"] accel = ["ciso8601 (>=2.1.2,<3.0.0)", "python-rapidjson", "uvloop (>=0.14.0,<0.15.0)"]
@ -606,7 +607,7 @@ asyncpg = ["asyncpg"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.7" python-versions = "^3.7"
content-hash = "27f12254888e96c2b78ba5d786091fbb0bc98efcff2d71b59f7165b5b6edb1a3" content-hash = "3b8e107e2fd01362244f27f783c8dcfd792e4ea3c98a0579e4b987e0c5681b5d"
[metadata.files] [metadata.files]
aiomysql = [ aiomysql = [
@ -755,8 +756,8 @@ iso8601 = [
{file = "iso8601-0.1.14.tar.gz", hash = "sha256:8aafd56fa0290496c5edbb13c311f78fa3a241f0853540da09d9363eae3ebd79"}, {file = "iso8601-0.1.14.tar.gz", hash = "sha256:8aafd56fa0290496c5edbb13c311f78fa3a241f0853540da09d9363eae3ebd79"},
] ]
isort = [ isort = [
{file = "isort-5.7.0-py3-none-any.whl", hash = "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc"}, {file = "isort-5.8.0-py3-none-any.whl", hash = "sha256:2bb1680aad211e3c9944dbce1d4ba09a989f04e238296c87fe2139faa26d655d"},
{file = "isort-5.7.0.tar.gz", hash = "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e"}, {file = "isort-5.8.0.tar.gz", hash = "sha256:0a943902919f65c5684ac4e0154b1ad4fac6dcaa5d9f3426b732f1c8b5419be6"},
] ]
mccabe = [ mccabe = [
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
@ -830,8 +831,9 @@ pyparsing = [
{file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"},
{file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"},
] ]
pypika = [ pypika-tortoise = [
{file = "pypika-0.44.1.tar.gz", hash = "sha256:316839144d3ad7656405a10cdd26d2181f16bb8ff7e256d616ffb50335ca1fcb"}, {file = "pypika-tortoise-0.1.0.tar.gz", hash = "sha256:7176e98ff0cf7c311d4ba58f28f1755956265dee2f9781e65e1304a67a3e5aa5"},
{file = "pypika_tortoise-0.1.0-py3-none-any.whl", hash = "sha256:ec83b0b2964be01ef563f5f019b0332a18177604e841c47ad39d798798c6dfe9"},
] ]
pytest = [ pytest = [
{file = "pytest-6.2.2-py3-none-any.whl", hash = "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839"}, {file = "pytest-6.2.2-py3-none-any.whl", hash = "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839"},
@ -940,8 +942,8 @@ toml = [
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
] ]
tortoise-orm = [ tortoise-orm = [
{file = "tortoise-orm-0.16.21.tar.gz", hash = "sha256:9729eac3eb58e59c32e2815d5ff1941a71e1eecd63834ae7199b6084c1a454b5"}, {file = "tortoise-orm-0.17.0.tar.gz", hash = "sha256:d59c9ba2e8f3bb165f6ba7880ae0f0127659aa143750de419850a06329ca27ff"},
{file = "tortoise_orm-0.16.21-py3-none-any.whl", hash = "sha256:f36aa16d07bab69b141e91f8791c0f878fbcc0acfffa3c671ea10a6ad73c54ed"}, {file = "tortoise_orm-0.17.0-py3-none-any.whl", hash = "sha256:39da891a61871a9e5e980007776c7d1f9b61e6b8601eb6482c90f89b30334638"},
] ]
typed-ast = [ typed-ast = [
{file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70"}, {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70"},

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "aerich" name = "aerich"
version = "0.5.1" version = "0.5.2"
description = "A database migrations tool for Tortoise ORM." description = "A database migrations tool for Tortoise ORM."
authors = ["long2ice <long2ice@gmail.com>"] authors = ["long2ice <long2ice@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"
@ -16,7 +16,7 @@ include = ["CHANGELOG.md", "LICENSE", "README.md"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.7"
tortoise-orm = "^0.16.21" tortoise-orm = "*"
click = "*" click = "*"
pydantic = "*" pydantic = "*"
aiomysql = { version = "*", optional = true } aiomysql = { version = "*", optional = true }