tortoise / aerich

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

`aerich migrate` fails with version `0.6.3` #238

Open fullonic opened 2 years ago

fullonic commented 2 years ago

Hi, I'm having issues when running aerich migrate using version 0.6.3. However, when downgrading to 0.6.2 the commands works properly.

Here is the complete traceback:

Traceback (most recent call last):
  File " .venv/bin/aerich", line 8, in <module>
    sys.exit(main())
  File " .venv/lib/python3.10/site-packages/aerich/cli.py", line 257, in main
    cli()
  File " .venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File " .venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File " .venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File " .venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File " .venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File " .venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File " .venv/lib/python3.10/site-packages/aerich/cli.py", line 31, in wrapper
    loop.run_until_complete(f(*args, **kwargs))
  File " .venv/lib/python3.10/site-packages/nest_asyncio.py", line 89, in run_until_complete
    return f.result()
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File " .venv/lib/python3.10/site-packages/aerich/cli.py", line 86, in migrate
    ret = await command.migrate(name)
  File " .venv/lib/python3.10/site-packages/aerich/__init__.py", line 126, in migrate
    return await Migrate.migrate(name)
  File " .venv/lib/python3.10/site-packages/aerich/migrate.py", line 140, in migrate
    return await cls._generate_diff_sql(name)
  File " .venv/lib/python3.10/site-packages/aerich/migrate.py", line 112, in _generate_diff_sql
    version = await cls.generate_version(name)
  File " .venv/lib/python3.10/site-packages/aerich/migrate.py", line 102, in generate_version
    last_version_num = await cls._get_last_version_num()
  File " .venv/lib/python3.10/site-packages/aerich/migrate.py", line 93, in _get_last_version_num
    last_version = await cls.get_last_version()
  File " .venv/lib/python3.10/site-packages/aerich/migrate.py", line 55, in get_last_version
    return await Aerich.filter(app=cls.app).first()
  File " .venv/lib/python3.10/site-packages/tortoise/queryset.py", line 1006, in _execute
    instance_list = await self._db.executor_class(
  File " .venv/lib/python3.10/site-packages/tortoise/backends/base/executor.py", line 130, in execute_select
    _, raw_results = await self.db.execute_query(query.get_sql())
  File " .venv/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 36, in translate_exceptions_
    return await func(self, *args)
  File " .venv/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 171, in execute_query
    async with self.acquire_connection() as connection:
  File " .venv/lib/python3.10/site-packages/tortoise/backends/base/client.py", line 303, in __aenter__
    self.connection = await self.pool.acquire()
AttributeError: 'NoneType' object has no attribute 'acquire'

tortoise-orm: 0.18.1
aerich: 0.6.3 asyncpg: 0.25.0

Thanks for your help

long2ice commented 2 years ago

Check your connection, I tried but is right

fullonic commented 2 years ago

Hi @long2ice, I just tried again and the problem persists. I'm running PostgreSQL locally and it goes well with 0.6.2 but not with 0.6.3. What kind of extra info can I provide? Thanks for your help

adityabond commented 2 years ago

seeing the same issue with aerich: 0.6.3 and tortoise-orm: 0.18.1

fullonic commented 2 years ago

@long2ice can you reproduce the error?

sakthiRatnam commented 2 years ago

seeing the same issue with aerich: 0.6.3 and tortoise-orm: 0.18.1

long2ice commented 2 years ago

Can't reproduce that

image
sakthiRathinam commented 2 years ago

@long2ice try with tortoise-orm latest version and asyncpg latest version

long2ice commented 2 years ago

The same, what about try this: https://github.com/tortoise/aerich#restore-aerich-workflow

sakthiRathinam commented 2 years ago

@long2ice i tried that too it's not working kindly check with more tortoise models not a simple model

TheBubblePopped commented 2 years ago

+1

web3gh commented 2 years ago

i have the same problem. is anything happening here?