Skip to content

Worflow for code in production? #515

@hellow554

Description

@hellow554

Hey everyone,

I have a (hopefully) simple question, which is not covered by the Readme IMHO.

I develop my app and use migrate all the time. The migration folders grows, I commit it to git -- nothing special so far.

My code looks something like this:

async def start_database() -> None:
    async with Command(
        tortoise_config=TORTOISE_ORM,
        app="windfish",
    ) as command:
        await command.upgrade()
        await command.init()

Now I have a server that I want my app to run. Typically that server does not have a database to start with. So I add something like await command.init_db(safe=True) to the code snippet above as the first line.

That does not work with the following error:

  File "src/windfish/__main__.py", line 19, in main
    await start_database()
  File "src/windfish/models/__init__.py", line 22, in start_database
    await command.init_db(safe=True)
  File ".venv/lib/python3.14/site-packages/aerich/__init__.py", line 237, in init_db
    await self._do_init(safe, pre_sql)
  File ".venv/lib/python3.14/site-packages/aerich/__init__.py", line 257, in _do_init
    raise FileExistsError(str(unexpected_file))
FileExistsError: migrations/windfish/__pycache__

That is unfortunate.

How is the workflow supposed to work? Should I check in advance if the database exists (works for me, because I use sqlite)?
Is there something I'm missing here?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions