-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于同一应用下不同models文件和不同应用的不同models文件如何初始化数据库? #24
Comments
对于相同app,将所有的models加入到tortoise配置中就行。 |
@long2ice |
1不支持,2就是你定义tortoise时的app,默认是models |
@long2ice |
好的,我试试 |
同时会有一个运行警告:RuntimeWarning: Module "aerich.models" has no models cls._init_apps(apps_config),但是好像是初始化成功了 |
init-db会创建表 |
我的理解是 --app models2 指定models2应用后就只是将models2涉及到的数据表创建到数据库中,难道我理解是不对的吗? |
估计是因为你两个connection是同一个吧 |
呃呃。。。,一个项目中有多个应用都是使用的一个连接呀,同一个connection应该是很正常的吧? |
那感觉没必要区分app,用models区分就行了 |
这不对吧,会创建所有注册的models才对 |
不好意思,刚才试了一下,可能是由于我两个models文件写的有问题,才导致会出现我的这个问题。我修改了一下其中的一个modles文件,不存在上面说的问题了。 |
I get an error too
aerich 0.2.1 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 class User(Model):
roles = fields.ManyToManyField("admin.Role", related_name="users") |
You should merge |
Can expect multiple applications in the same database in the future? |
No,that's no need |
@long2ice 您好,我在使用aerich init-db时有2个疑惑,自己初步试了一下,没能成功。
疑惑1:初始化数据库时,同一个app应用下有多个models文件,例如models目录下有models1.py和models2.py,在初始化时要如何初始化?
疑惑2:初始化数据库时,不同应用如何初始化,例如app1应用下有一个app1_models.py,app2应用下有一个app2_models.py,在初始化时要如何初始化?
The text was updated successfully, but these errors were encountered: