tortoise / aerich

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

aerich_pkey Key (id)=(1) already exists #137

Open Olegt0rr opened 3 years ago

Olegt0rr commented 3 years ago

Something went wrong

tortoise.exceptions.IntegrityError: duplicate key value violates unique constraint "aerich_pkey"
 DETAIL:  Key (id)=(1) already exists.

How to reproduce

 Traceback (most recent call last):
 File "/app/venv/bin/aerich", line 10, in <module>
 sys.exit(main())
 File "/app/venv/lib64/python3.8/site-packages/aerich/cli.py", line 315, in main
 cli()
 File "/app/venv/lib64/python3.8/site-packages/click/core.py", line 829, in __call__
 return self.main(*args, **kwargs)
 File "/app/venv/lib64/python3.8/site-packages/click/core.py", line 782, in main
 rv = self.invoke(ctx)
 File "/app/venv/lib64/python3.8/site-packages/click/core.py", line 1259, in invoke
 return _process_result(sub_ctx.command.invoke(sub_ctx))
 File "/app/venv/lib64/python3.8/site-packages/click/core.py", line 1066, in invoke
 return ctx.invoke(self.callback, **ctx.params)
 File "/app/venv/lib64/python3.8/site-packages/click/core.py", line 610, in invoke
 return callback(*args, **kwargs)
 File "/app/venv/lib64/python3.8/site-packages/click/decorators.py", line 21, in new_func
 return f(get_current_context(), *args, **kwargs)
 File "/app/venv/lib64/python3.8/site-packages/aerich/cli.py", line 41, in wrapper
 loop.run_until_complete(f(*args, **kwargs))
 File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
 return future.result()
 File "/app/venv/lib64/python3.8/site-packages/aerich/cli.py", line 124, in upgrade
 await Aerich.create(
 File "/app/venv/lib64/python3.8/site-packages/tortoise/models.py", line 1062, in create
 await instance.save(using_db=db, force_create=True)
 File "/app/venv/lib64/python3.8/site-packages/tortoise/models.py", line 906, in save
 await executor.execute_insert(self)
 File "/app/venv/lib64/python3.8/site-packages/tortoise/backends/base/executor.py", line 203, in execute_insert
 insert_result = await self.db.execute_insert(self.insert_query, values)
 File "/app/venv/lib64/python3.8/site-packages/tortoise/backends/asyncpg/client.py", line 40, in translate_exceptions_
 raise IntegrityError(exc)
 tortoise.exceptions.IntegrityError: duplicate key value violates unique constraint "aerich_pkey"
 DETAIL:  Key (id)=(1) already exists.