Indexing 对于索引为true列的SQLalchemy中的表,Alembic迁移会导致重复索引错误

Indexing 对于索引为true列的SQLalchemy中的表,Alembic迁移会导致重复索引错误,indexing,sqlalchemy,database-migration,alembic,sqlalchemy-migrate,Indexing,Sqlalchemy,Database Migration,Alembic,Sqlalchemy Migrate,我以前的型号: class sample(Base): __tablename__ = "sample" id = Column(BigInteger, primary_key=True,index=True) name = Column(String(30),index=True) class sample(Base): __tablename__ = "sample" id = Column(String(length=1000), primary_

我以前的型号:

class sample(Base):
    __tablename__ = "sample"
    id = Column(BigInteger, primary_key=True,index=True)
    name = Column(String(30),index=True)
class sample(Base):
    __tablename__ = "sample"
    id = Column(String(length=1000), primary_key=True,index=True))
    name = Column(String(30),index=True)
def upgrade():
    op.create_index(op.f('ix_sample_name'), 'sample', ['name'], unique=False)
    op.drop_index('ix_sample_name', table_name='sample')
    op.alter_column('sample', 'id',
               existing_type=mysql.BIGINT(display_width=20),
               type_=sa.String(length=1000))
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1061, "Duplicate key name 'ix_userdetails_firstName'")
[SQL: CREATE INDEX `ix_userdetails_firstName` ON userdetails (`firstName`)]
(Background on this error at: http://sqlalche.me/e/e3q8)
我的最新型号:

class sample(Base):
    __tablename__ = "sample"
    id = Column(BigInteger, primary_key=True,index=True)
    name = Column(String(30),index=True)
class sample(Base):
    __tablename__ = "sample"
    id = Column(String(length=1000), primary_key=True,index=True))
    name = Column(String(30),index=True)
def upgrade():
    op.create_index(op.f('ix_sample_name'), 'sample', ['name'], unique=False)
    op.drop_index('ix_sample_name', table_name='sample')
    op.alter_column('sample', 'id',
               existing_type=mysql.BIGINT(display_width=20),
               type_=sa.String(length=1000))
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1061, "Duplicate key name 'ix_userdetails_firstName'")
[SQL: CREATE INDEX `ix_userdetails_firstName` ON userdetails (`firstName`)]
(Background on this error at: http://sqlalche.me/e/e3q8)
我运行了命令
alembic revision--autogenerate-m“将id字段类型更改为字符串”

生成的我的迁移详细信息:

class sample(Base):
    __tablename__ = "sample"
    id = Column(BigInteger, primary_key=True,index=True)
    name = Column(String(30),index=True)
class sample(Base):
    __tablename__ = "sample"
    id = Column(String(length=1000), primary_key=True,index=True))
    name = Column(String(30),index=True)
def upgrade():
    op.create_index(op.f('ix_sample_name'), 'sample', ['name'], unique=False)
    op.drop_index('ix_sample_name', table_name='sample')
    op.alter_column('sample', 'id',
               existing_type=mysql.BIGINT(display_width=20),
               type_=sa.String(length=1000))
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1061, "Duplicate key name 'ix_userdetails_firstName'")
[SQL: CREATE INDEX `ix_userdetails_firstName` ON userdetails (`firstName`)]
(Background on this error at: http://sqlalche.me/e/e3q8)
我在升级磁头(alembic升级磁头)时遇到以下错误:

class sample(Base):
    __tablename__ = "sample"
    id = Column(BigInteger, primary_key=True,index=True)
    name = Column(String(30),index=True)
class sample(Base):
    __tablename__ = "sample"
    id = Column(String(length=1000), primary_key=True,index=True))
    name = Column(String(30),index=True)
def upgrade():
    op.create_index(op.f('ix_sample_name'), 'sample', ['name'], unique=False)
    op.drop_index('ix_sample_name', table_name='sample')
    op.alter_column('sample', 'id',
               existing_type=mysql.BIGINT(display_width=20),
               type_=sa.String(length=1000))
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1061, "Duplicate key name 'ix_userdetails_firstName'")
[SQL: CREATE INDEX `ix_userdetails_firstName` ON userdetails (`firstName`)]
(Background on this error at: http://sqlalche.me/e/e3q8)
Alembic正在尝试删除现有索引并尝试创建另一个索引,但我不想再次创建或删除索引,直到该特定列发生任何更改。 我怎样才能做到这一点