---
title: "💭 `ValueError: Constraint must have a name` in alembic 1.10.0 · ..."
description: "!https://github.com/sqlalchemy/alembic/issues/1195"
date: 2023-08-05
published: true
tags:
  - python
  - data
  - database
  - alembic
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://github.com/sqlalchemy/alembic/issues/1195" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-image">
      <img src="https://opengraph.githubassets.com/bb02b91b671faac0db0047bb0b8d3886debbe893813cf6ef68ecddbd0932a469/sqlalchemy/alembic/issues/1195" alt="`ValueError: Constraint must have a name` in alembic 1.10.0 · Issue #1195 · sqlalchemy/alembic — Describe the bug ValueError: Constraint must have a name in alembic 1.10.0. Expected behavior Migration succeeds. To Reproduce Please try to provide a Minimal, Complete, and Verifiable example, wit..." loading="lazy">
    </div>
    <div class="embed-card-content">
      <div class="embed-card-title">`ValueError: Constraint must have a name` in alembic 1.10.0 · Issue #1195 · sqlalchemy/alembic</div>
      <div class="embed-card-description">Describe the bug ValueError: Constraint must have a name in alembic 1.10.0. Expected behavior Migration succeeds. To Reproduce Please try to provide a Minimal, Complete, and Verifiable example, wit...</div>
      <div class="embed-card-meta">GitHub &middot; github.com</div>
    </div>
  </a>
</div>


After a nasty time with alembic upgrades, thoughts is about to get a new users table.  This may have came from incorrectly setting up alembic for sqlite from the start, but I was able to fix the issue with this GitHub issue.

``` python
alembic sqlite ValueError: Constraint must have a name
```

The change I needed to make to get my migration to run.

``` diff        - batch_op.create_foreign_key(None, 'user', ['author_id'], ['id'])

        + batch_op.create_foreign_key('fk_post_author_id_user', 'user', ['author_id'], ['id'])
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
