After using flask-migrate to upgrade for the first time, migrate an error again?

< H2 > db_demo3.py < / H2 >
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import config

app = Flask(__name__)
app.config.from_object(config)
db = SQLAlchemy(app)

db.create_all()

@app.route("/")
def index():
    return "hello world"
   
if __name__ == "__main__":
    app.run(debug=True)
< H2 > models.py < / H2 >
from db_demo3 import db

class Users(db.Model):
    __tablename__ = "users"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(100), nullable=True)
    telephone = db.Column(db.String(11))
< H2 > manage.py < / H2 >
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from db_demo3 import app, db
from models import Users

manager = Manager(app)

migrate = Migrate(app, db)

manager.add_command("db", MigrateCommand)

if __name__ == "__main__":
    manager.run()

code as above, run

in turn from the command line
python manage.py db init
python manage.py db migrate
python manage.py db upgrade

No error was reported and the version file and database form were generated successfully
but after running python manage.py db migrate again without any modification, the error was reported:

C:\Users\LKS00085\Python\learn flask\db_demo3>python manage.py db migrate
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Traceback (most recent call last):
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 348, in
 _revision_for_ident
    revision = self._revision_map[resolved_id]
KeyError: 51

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    manager.run()
  File "D:\Anaconda3\lib\site-packages\flask_script\__init__.py", line 417, in r
un
    result = self.handle(argv[0], argv[1:])
  File "D:\Anaconda3\lib\site-packages\flask_script\__init__.py", line 386, in h
andle
    res = handle(*args, **config)
  File "D:\Anaconda3\lib\site-packages\flask_script\commands.py", line 216, in _
_call__
    return self.run(*args, **kwargs)
  File "D:\Anaconda3\lib\site-packages\flask_migrate\__init__.py", line 197, in
migrate
    version_path=version_path, rev_id=rev_id)
  File "D:\Anaconda3\lib\site-packages\alembic\command.py", line 117, in revisio
n
    script_directory.run_env()
  File "D:\Anaconda3\lib\site-packages\alembic\script\base.py", line 416, in run
_env
    util.load_python_file(self.dir, "env.py")
  File "D:\Anaconda3\lib\site-packages\alembic\util\pyfiles.py", line 93, in loa
d_python_file
    module = load_module_py(module_id, path)
  File "D:\Anaconda3\lib\site-packages\alembic\util\compat.py", line 68, in load
_module_py
    module_id, path).load_module(module_id)
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrappe
r
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 251, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 675, in _load
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "migrations\env.py", line 87, in <module>
    run_migrations_online()
  File "migrations\env.py", line 80, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "D:\Anaconda3\lib\site-packages\alembic\runtime\environment.py", line 807
, in run_migrations
    self.get_context().run_migrations(**kw)
  File "D:\Anaconda3\lib\site-packages\alembic\runtime\migration.py", line 312,
in run_migrations
    for step in self._migrations_fn(heads, self):
  File "D:\Anaconda3\lib\site-packages\alembic\command.py", line 97, in retrieve
_migrations
    revision_context.run_autogenerate(rev, context)
  File "D:\Anaconda3\lib\site-packages\alembic\autogenerate\api.py", line 369, i
n run_autogenerate
    self._run_environment(rev, migration_context, True)
  File "D:\Anaconda3\lib\site-packages\alembic\autogenerate\api.py", line 379, i
n _run_environment
    if set(self.script_directory.get_revisions(rev)) != \
  File "D:\Anaconda3\lib\site-packages\alembic\script\base.py", line 201, in get
_revisions
    return self.revision_map.get_revisions(id_)
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 298, in
 get_revisions
    return sum([self.get_revisions(id_elem) for id_elem in id_], ())
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 298, in
 <listcomp>
    return sum([self.get_revisions(id_elem) for id_elem in id_], ())
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 303, in
 get_revisions
    for rev_id in resolved_id)
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 303, in
 <genexpr>
    for rev_id in resolved_id)
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 351, in
 _revision_for_ident
    revs = [x for x in self._revision_map
  File "D:\Anaconda3\lib\site-packages\alembic\script\revision.py", line 352, in
 <listcomp>
    if x and x.startswith(resolved_id)]
TypeError: <flask_script.commands.Command object at 0x0000000004E44E80>: startsw
ith first arg must be str or a tuple of str, not int

just started to learn the flask framework, doing a project exercise, there is no solution to the relevant error report, please give me more advice, thank you!

Mar.13,2021

Delete your migration/ folder and try again.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5112d-4445b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5112d-4445b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?