Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cd176c1fd6 | ||
|
c2819fc8dc | ||
|
530e7cfce5 | ||
|
47824a100b | ||
|
78a15f9f19 | ||
|
e0d52b1210 | ||
|
4dc45f723a |
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## 0.4
|
## 0.4
|
||||||
|
|
||||||
|
### 0.4.4
|
||||||
|
|
||||||
|
- Fix unnecessary import. (#113)
|
||||||
|
|
||||||
### 0.4.3
|
### 0.4.3
|
||||||
|
|
||||||
- Replace migrations separator to sql standard comment.
|
- Replace migrations separator to sql standard comment.
|
||||||
|
@@ -1 +1 @@
|
|||||||
__version__ = "0.4.3"
|
__version__ = "0.4.4"
|
||||||
|
@@ -240,8 +240,7 @@ async def init(
|
|||||||
with open(config_file, "w", encoding="utf-8") as f:
|
with open(config_file, "w", encoding="utf-8") as f:
|
||||||
parser.write(f)
|
parser.write(f)
|
||||||
|
|
||||||
if not Path(location).is_dir():
|
Path(location).mkdir(parents=True, exist_ok=True)
|
||||||
os.mkdir(location)
|
|
||||||
|
|
||||||
click.secho(f"Success create migrate location {location}", fg=Color.green)
|
click.secho(f"Success create migrate location {location}", fg=Color.green)
|
||||||
click.secho(f"Success generate config file {config_file}", fg=Color.green)
|
click.secho(f"Success generate config file {config_file}", fg=Color.green)
|
||||||
@@ -263,10 +262,10 @@ async def init_db(ctx: Context, safe):
|
|||||||
app = ctx.obj["app"]
|
app = ctx.obj["app"]
|
||||||
|
|
||||||
dirname = Path(location, app)
|
dirname = Path(location, app)
|
||||||
if not dirname.is_dir():
|
try:
|
||||||
os.mkdir(dirname)
|
dirname.mkdir(parents=True)
|
||||||
click.secho(f"Success create app migrate location {dirname}", fg=Color.green)
|
click.secho(f"Success create app migrate location {dirname}", fg=Color.green)
|
||||||
else:
|
except FileExistsError:
|
||||||
return click.secho(
|
return click.secho(
|
||||||
f"Inited {app} already, or delete {dirname} and try again.", fg=Color.yellow
|
f"Inited {app} already, or delete {dirname} and try again.", fg=Color.yellow
|
||||||
)
|
)
|
||||||
|
@@ -3,7 +3,6 @@ from typing import List, Optional
|
|||||||
|
|
||||||
from ddlparse import DdlParse
|
from ddlparse import DdlParse
|
||||||
from tortoise import BaseDBAsyncClient
|
from tortoise import BaseDBAsyncClient
|
||||||
from tortoise.backends.mysql.client import MySQLSchemaGenerator
|
|
||||||
|
|
||||||
|
|
||||||
class InspectDb:
|
class InspectDb:
|
||||||
@@ -24,7 +23,7 @@ class InspectDb:
|
|||||||
self.DIALECT = conn.schema_generator.DIALECT
|
self.DIALECT = conn.schema_generator.DIALECT
|
||||||
|
|
||||||
async def show_create_tables(self):
|
async def show_create_tables(self):
|
||||||
if self.DIALECT == MySQLSchemaGenerator.DIALECT:
|
if self.DIALECT == "mysql":
|
||||||
if not self.tables:
|
if not self.tables:
|
||||||
sql_tables = f"SELECT table_name FROM information_schema.tables WHERE table_schema = '{self.conn.database}';" # nosec: B608
|
sql_tables = f"SELECT table_name FROM information_schema.tables WHERE table_schema = '{self.conn.database}';" # nosec: B608
|
||||||
ret = await self.conn.execute_query(sql_tables)
|
ret = await self.conn.execute_query(sql_tables)
|
||||||
|
@@ -5,6 +5,7 @@ from datetime import datetime
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from types import ModuleType
|
||||||
from typing import Dict, List, Optional, Tuple, Type
|
from typing import Dict, List, Optional, Tuple, Type
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -210,7 +211,10 @@ class Migrate:
|
|||||||
old_model_files = []
|
old_model_files = []
|
||||||
models = config.get("apps").get(app).get("models")
|
models = config.get("apps").get(app).get("models")
|
||||||
for model in models:
|
for model in models:
|
||||||
module = import_module(model)
|
if isinstance(model, ModuleType):
|
||||||
|
module = model
|
||||||
|
else:
|
||||||
|
module = import_module(model)
|
||||||
possible_models = [getattr(module, attr_name) for attr_name in dir(module)]
|
possible_models = [getattr(module, attr_name) for attr_name in dir(module)]
|
||||||
for attr in filter(
|
for attr in filter(
|
||||||
lambda x: inspect.isclass(x) and issubclass(x, Model) and x is not Model,
|
lambda x: inspect.isclass(x) and issubclass(x, Model) and x is not Model,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "aerich"
|
name = "aerich"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
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"
|
||||||
|
Reference in New Issue
Block a user