Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cd176c1fd6 | ||
|
c2819fc8dc | ||
|
530e7cfce5 | ||
|
47824a100b | ||
|
78a15f9f19 | ||
|
e0d52b1210 | ||
|
4dc45f723a |
@@ -2,6 +2,10 @@
|
||||
|
||||
## 0.4
|
||||
|
||||
### 0.4.4
|
||||
|
||||
- Fix unnecessary import. (#113)
|
||||
|
||||
### 0.4.3
|
||||
|
||||
- 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:
|
||||
parser.write(f)
|
||||
|
||||
if not Path(location).is_dir():
|
||||
os.mkdir(location)
|
||||
Path(location).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
click.secho(f"Success create migrate location {location}", 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"]
|
||||
|
||||
dirname = Path(location, app)
|
||||
if not dirname.is_dir():
|
||||
os.mkdir(dirname)
|
||||
try:
|
||||
dirname.mkdir(parents=True)
|
||||
click.secho(f"Success create app migrate location {dirname}", fg=Color.green)
|
||||
else:
|
||||
except FileExistsError:
|
||||
return click.secho(
|
||||
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 tortoise import BaseDBAsyncClient
|
||||
from tortoise.backends.mysql.client import MySQLSchemaGenerator
|
||||
|
||||
|
||||
class InspectDb:
|
||||
@@ -24,7 +23,7 @@ class InspectDb:
|
||||
self.DIALECT = conn.schema_generator.DIALECT
|
||||
|
||||
async def show_create_tables(self):
|
||||
if self.DIALECT == MySQLSchemaGenerator.DIALECT:
|
||||
if self.DIALECT == "mysql":
|
||||
if not self.tables:
|
||||
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)
|
||||
|
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
from importlib import import_module
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Dict, List, Optional, Tuple, Type
|
||||
|
||||
import click
|
||||
@@ -210,7 +211,10 @@ class Migrate:
|
||||
old_model_files = []
|
||||
models = config.get("apps").get(app).get("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)]
|
||||
for attr in filter(
|
||||
lambda x: inspect.isclass(x) and issubclass(x, Model) and x is not Model,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "aerich"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
description = "A database migrations tool for Tortoise ORM."
|
||||
authors = ["long2ice <long2ice@gmail.com>"]
|
||||
license = "Apache-2.0"
|
||||
|
Reference in New Issue
Block a user