tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
843 stars 96 forks source link

how to init a new database #62

Closed neo-f closed 3 years ago

neo-f commented 4 years ago

使用版本:0.3.1 开发环境下初始化好migrations/models/xxx.json之后提交代码

目前尝试在一个新环境下(新数据库)初始化项目

  1. 执行aerich upgrade会提示relation "aerich" does not exist
  2. 执行aerich init-db会提示Inited models already 并且数据库中无任何变更

似乎是一个BUG?或者有无解决方案

long2ice commented 4 years ago

先执行aerich init再执行aerich init-db,或者删除migrations/models目录再执行init-db

lucekdudek commented 4 years ago

Hi, I have the same issue. I wish I am able to apply migrations generated in local environment and then apply them to new instance of DB server from migrations files. Right now aerich init-db make two things: 1) generates migrations files, 2) apply them to DB. In my opinion user of this repository should be able to generate migrations without DB and then applying migrations to DB in which relation "aerich" does not exist.

Quick fix for this would be to change aerich upgrade so it creates relation "aerich" if not exist but a more welcome change would be to allow migration generation without live DB.

long2ice commented 4 years ago

Fixed in https://github.com/tortoise/aerich/commit/6339dc86a8cdbe8311e3df9b279d95b14a91a3a4