Comments (20)
No,that's no need
from aerich.
对于相同app,将所有的models加入到tortoise配置中就行。
对于不同app,指定--app即可。
from aerich.
@long2ice
对于相同app,如果我只想迁移models2.py中的相关东西,要怎么操作?
对于不同app,--app 后面跟的时models文件的路径吗?我试了一下,没有成果。
from aerich.
1不支持,2就是你定义tortoise时的app,默认是models
from aerich.
@long2ice
定义tortoise时的app?tortoise中没有定义app呀,您说的是app=FastAPI()这个app么?
from aerich.
from aerich.
好的,我试试
from aerich.
我试了一下,如果使用aerich --app models2 init-db 会同时把models你面的模型初始到数据库,这样是对的吗?
from aerich.
同时会有一个运行警告:RuntimeWarning: Module "aerich.models" has no models cls._init_apps(apps_config),但是好像是初始化成功了
from aerich.
init-db会创建表
from aerich.
我的理解是 --app models2 指定models2应用后就只是将models2涉及到的数据表创建到数据库中,难道我理解是不对的吗?
from aerich.
估计是因为你两个connection是同一个吧
from aerich.
呃呃。。。,一个项目中有多个应用都是使用的一个连接呀,同一个connection应该是很正常的吧?
from aerich.
那感觉没必要区分app,用models区分就行了
from aerich.
好的,理解了,但是针对您说的对于相同app,将所有的models加入到tortoise配置中就行。我试了一下,只会在数据库中创建列表中最后面的models对应的数据表,如下图:
from aerich.
这不对吧,会创建所有注册的models才对
from aerich.
不好意思,刚才试了一下,可能是由于我两个models文件写的有问题,才导致会出现我的这个问题。我修改了一下其中的一个modles文件,不存在上面说的问题了。
from aerich.
I get an error too RuntimeWarning: Module "aerich.models"
aerich heads
/usr/local/lib/python3.7/dist-packages/tortoise/__init__.py:556: RuntimeWarning: Module "aerich.models" has no models
cls._init_apps(apps_config)
No available heads,try migrate
aerich 0.2.1
tortoise-orm 0.16.12
tortoise connection config:
{
"apps": {
"admin": {
"models": ["test.admin_model", "aerich.models"]
},
"test": {
"models": ["test.model", "aerich.models"]
}
},
"connections": {
"default": {
"credentials": {
"database": "test",
"host": "db",
"password": "*********",
"port": 5432,
"user": "nemo"
},
"engine": "tortoise.backends.asyncpg",
"maxsize": 3,
"minsize": 1
}
}
}
This is one application, but I have to split it, because there is a relationship
test.admin_model.py
class User(Model):
roles = fields.ManyToManyField("admin.Role", related_name="users")
from aerich.
You should merge admin
and test
and keep one aerich.models
from aerich.
Can expect multiple applications in the same database in the future?
from aerich.
Related Issues (20)
- aerich upgrade error with \windows_events.py", line 494, in finish_recv return ov.getresult() OSError: [WinError 64] 指定的网络名不再可用。 HOT 3
- 在已有项目添加新的模型后 无法upgrade HOT 3
- side cache
- Initialise an existing project in a new environment HOT 3
- ?sslmode=disable unexpected keyword argument HOT 1
- Can't delete m2m relation HOT 1
- Error running upgrade on Postgres HOT 2
- please support mssql
- Can we simplify the migration file generated by aerich migrate
- Nested database transactions
- varchar max_length change not detected HOT 2
- Improved feedback for "migrate" when models and schema are in sync
- aerich inspectdb makes syntax error
- Pydantic validation error when inspecting DB HOT 4
- AttributeError: 'method_descriptor' object has no attribute '__module__'. Did you mean: '__reduce__'? HOT 1
- stuck on init HOT 13
- FK column rename error
- FK column unique not working
- migrate() got an unexpected keyword argument 'empty' HOT 2
- Model with multiple FKs to same table throws error or finds changes that aren't there
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aerich.