Closed songjinu closed 1 week ago
To resolve the error related to a duplicate 'folder_id' in Alembic in the file src/backend/base/langflow/alembic/versions/012fb73ac359_add_folder_table.py
, you need to ensure that the column folder_id
is not being added multiple times. The issue might be due to the drop_column("folder")
line, which should be drop_column("folder_id")
instead.
Here is the corrected upgrade
function:
def upgrade() -> None:
conn = op.get_bind()
inspector = Inspector.from_engine(conn) # type: ignore
table_names = inspector.get_table_names()
# ### commands auto generated by Alembic - please adjust! ###
if "folder" not in table_names:
op.create_table(
"folder",
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("parent_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
sa.Column("user_id", sqlmodel.sql.sqltypes.GUID(), nullable=True),
sa.ForeignKeyConstraint(
["parent_id"],
["folder.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
)
indexes = inspector.get_indexes("folder")
if "ix_folder_name" not in [index["name"] for index in indexes]:
with op.batch_alter_table("folder", schema=None) as batch_op:
batch_op.create_index(batch_op.f("ix_folder_name"), ["name"], unique=False)
if "folder_id" not in inspector.get_columns("flow"):
with op.batch_alter_table("flow", schema=None) as batch_op:
batch_op.add_column(sa.Column("folder_id", sqlmodel.sql.sqltypes.GUID(), nullable=True))
batch_op.create_foreign_key("flow_folder_id_fkey", "folder", ["folder_id"], ["id"])
batch_op.drop_column("folder_id")
# ### end Alembic commands ###
This change ensures that the folder_id
column is correctly managed without causing duplication errors [1].
To continue the conversation, mention @dosu.
Hello, Sorry for the delay. Did you try using the new version? Does the error still persist?
Hi @songjinu , I hope you're doing well. Just a friendly reminder that if we do not hear back from you within the next 3 days, we will close this issue. If you need more time or further assistance, please let us know.
Thank you for your understanding!
Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.
Describe the bug The error - duplicate 'folder_id' in alembic
at src/backend/base/langflow/alembic/versions/012fb73ac359_add_folder_table.py
inspector.get_columns("flow") return List[Dict] I modifed like this
Browser and Version