Open mkohei opened 3 months ago
🤖
Hey @mkohei! 🚀 Great to see you back. Hope you're ready for another round of troubleshooting adventure with Langflow!
Based on the information you've provided, it seems like you're encountering a similar issue to the ones reported in these two issues: Alembic DB migration error in Langflow v0.6.0 with PostgreSQL and The migration is failed when the database is postgresql.
The errors you're seeing, RuntimeError: Something went wrong running migrations
and InternalError: (psycopg2.errors.InFailedSqlTransaction) current transaction is aborted, commands ignored until end of transaction block
, are likely due to discrepancies between your current database schema and the schema defined in the migration scripts.
The langflow migration --fix
command is designed to resolve such issues by downgrading and upgrading the database schema until it matches the schema defined in the migration scripts. However, if this command does not resolve the issue, it could be due to a more serious problem with the database schema or the migration scripts themselves.
Here are a few steps you could try:
In the Hotfix 0.6.2 commit that resolved the similar issue, four new columns were added to the 'flow' table, an index was created on the 'user_id' column, and a foreign key was created that references the 'id' column in the 'user' table. You can find more details about these changes in the commit.
If these steps do not resolve your issue, could you provide more specific information about your database schema, the migration scripts, and the exact SQL command that is failing? This information could help identify the root cause of the issue.
ALTER TABLE apikey ADD CONSTRAINT uq_apikey_id UNIQUE(id);
ALTER TABLE flow ADD CONSTRAINT uq_flow_id UNIQUE(id);
ALTER TABLE user ADD CONSTRAINT uq_user_id UNIQUE(id);
Hey @mkohei
I'm having trouble with that too lately.
I'm considering improving the migration fix script to back up the database first, then rebuilding it and reinserting the data.
have this issue when deploy a new langflow with empty postgresql database. langflow version 0.6.4
Hello everyone, is there any improvements regarding this problem? I am having same issue lately but didn't have a chance to overcome. Do you have any suggestions or work around?
Hi everyone.
I have release a fix for this in the latest version and managed to get it working locally.
Unfortunately, it seems some cases are still not working so what I need from you all is the output of the following:
cd src/backend/langflow
LANGFLOW_DATABASE_URL=<your database url here> poetry run alembic check
Or, you could just get the output when you run langflow INCLUDING the part where it says:
alembic.util.exc.AutogenerateDiffsDetected: New upgrade operations ...
Hi everyone.
I have release a fix for this in the latest version and managed to get it working locally.
Unfortunately, it seems some cases are still not working so what I need from you all is the output of the following:
cd src/backend/langflow LANGFLOW_DATABASE_URL=<your database url here> poetry run alembic check
Or, you could just get the output when you run langflow INCLUDING the part where it says:
alembic.util.exc.AutogenerateDiffsDetected: New upgrade operations ...
When I applied this
cd src/backend/langflow LANGFLOW_DATABASE_URL=<your database url here> poetry run alembic check
The result is
024-03-10 15:31:46.072 | DEBUG | langflow.services.manager:_create_service:48 - Create service database_service 2024-03-10 15:31:46.072 | ERROR | env_py:run_migrations_online:92 - Error getting database engine: No factory registered for the service class 'DATABASE_SERVICE' INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. ERROR [alembic.util.messaging] Target database is not up to date. FAILED: Target database is not up to date.
What I did I created a .env and installed the node and poetry. I create .env file commented out the sqlite database URL and past my postgre db URL as LANGFLOW_DATABASE_URL = xxx . It didn't workout even I cleaned the target database.
Ok. I think the command might not be correct. Since you know your way around the repo.
Could you go to the file src/backend/langflow/alembic.ini
and in the line where it writes sqlalchemy.url ...
replace the SQLite url with your database url, then try running the command again, please. No need to pass the Langflow database url variable again.
Okay,I did update sqlalchemy.url ... in alembic.ini and then run the same command and here is the result: LANGFLOW_DATABASE_URL=postgresqlxxx poetry run alembic check 2024-03-10 18:19:11.217 | DEBUG | langflow.services.manager:_create_service:48 - Create service database_service 2024-03-10 18:19:11.217 | ERROR | env_py:run_migrations_online:70 - Error getting database engine: No factory registered for the service class 'DATABASE_SERVICE' INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. ERROR [alembic.util.messaging] Target database is not up to date. FAILED: Target database is not up to date. Note: I am using schema in the Postgres database(I think I should apply the schema into alembic/ .env dile), also should I update the .env database URL either?
Good.
Could try running poetry run alembic history
and poetry run alembic upgrade head
, please?
@Alperemrehas If you are ok with dumping the database, I can run the tests with it on my end to get to the bottom of this. You can send it to me on discord.
@Alperemrehas If you are ok with dumping the database, I can run the tests with it on my end to get to the bottom of this. You can send it to me on discord.
@ogabrielluiz Yes, I can try that and let you know.
@Alperemrehas If you are ok with dumping the database, I can run the tests with it on my end to get to the bottom of this. You can send it to me on discord.
@ogabrielluiz Yes, I can try that and let you know.
Hello everyone,
Unfortunantly, I was not able to solve this migration issue.
What I tried so far:
I pulled a postgre docker and run the docker to create the URL.
After that I have updated LANGFLOW_DATABASE_URL to postsql URL.
But when I run the poetry run alembic upgrade head command same error occured.
The interesting part actually whenever I tried to make backend and frontend after creating .env file it crashes eventhough keeping the database url same didn't make any difference.
That is so weird. I'm going to get to the bottom of this and update it asap.
I've updated it and pushed version 0.6.14
Had the same issue. Just installed and ran the pre-release version and it's now working.
python -m pip install langflow --pre --force-reinstall
Same issue, once i force-reinstalled the langflow from 0.6 to the pre-release version.
I've updated it and pushed version 0.6.14
Hello Gabriel,
Thank you for your ongoing support. I wanted to inform you that I've tested version 0.6.14 thoroughly, particularly with .env files containing updated LANGFLOW_DATABASE_URL
, and it worked smoothly. However, I encountered an issue specifically when using PostgreSQL on Azure resources.
Azure requires the presence of an "@" symbol in PostgreSQL passwords. Unfortunately, during Alembic initialization, the use of a single "%40" to represent "@" failed. To address this, I've implemented a fix in version 0.6.14. I've extensively tested this fix with PostgreSQL passwords containing "@" symbols on Azure resources, and it's functioning impeccably.
I believe this fix will alleviate the problem for others encountering the same issue.
Describe the bug
When using PostgreSQL as the database for Langflow version 0.6, an error occurs during the DB migration process. Despite the log suggesting to run
langflow migration --fix
, executing this command does not resolve the error.Browser and Version
To Reproduce
Steps to reproduce the behavior:
compose.yaml
andDockerfile
.docker compose up
.langflow migration --fix
and note the error persists.Additional context
Directory Structure:
compose.yaml
Dockerfile
Error log at start-up
Error log when running
langflow migration --fix