Skip to content

chatflow and workflow cannot be created, after updating to the latest main code #28046

Closed

Description

@IthacaDream

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

main

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

create a chatflow or workflow will report the following error:

sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "updated_at" of relation "workflows" violates not-null constraint
DETAIL:  Failing row contains (af67e558-ac38-42a1-a345-af7828280b33, 3880eb31-1ca0-4e2a-a012-e01e56065298, 17a669b3-6300-4fb5-a9db-f76ec31e358c, chat, draft, {"nodes": [{"id": "1762761957220", "type": "custom", "data": {"v..., {"retriever_resource": {"enabled": true}, "file_upload": {}, "op..., 7bfc1f4b-a3e2-4701-9559-2825f1beefaa, 2025-11-10 08:05:57, null, null, {}, {}, , , {}).

✔️ Expected Behavior

❌ Actual Behavior

No response

Activity

  1. added
    🐞 bug
    on Nov 10, 2025
  2. dosubot commented on Nov 10, 2025

    @dosubot

    This error is caused by a mismatch between the ORM model and your actual database schema after updating to the latest main code. PR #28014 changed the workflows.updated_at field to use onupdate=func.current_timestamp() but kept server_default=func.current_timestamp() in the model definition. However, if your database schema did not get updated correctly, new workflow/chatflow inserts can result in a null value for updated_at, violating the NOT NULL constraint and causing the integrity error you’re seeing (PR #28014 details).

    There is an open issue tracking this bug (issue #28046). The recommended fix is to ensure your database schema sets a default value for the workflows.updated_at column. For self-hosted setups, you can manually apply a migration like:

    ALTER TABLE workflows ALTER COLUMN updated_at SET DEFAULT CURRENT_TIMESTAMP;

    After running this, restart your application and new workflows/chatflows should be created without error. If you use Alembic for migrations, make sure your migration scripts reflect this change.

    To reply, just mention @dosu.


    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions