2

I have two tables in the same migration:

op.create_table(
        "oauth2_code",
        sa.Column("code", sa.String(length=120), nullable=False),
        sa.Column("client_id", sa.String(length=48), nullable=True),
        sa.Column("redirect_uri", sa.Text(), nullable=True),
        sa.Column("response_type", sa.Text(), nullable=True),
        sa.Column("scope", sa.Text(), nullable=True),
        sa.Column("nonce", sa.Text(), nullable=True),
        sa.Column("auth_time", sa.Integer(), nullable=False),
        sa.Column("code_challenge", sa.Text(), nullable=True),
        sa.Column("code_challenge_method", sa.String(length=48), nullable=True),
        sa.Column("id", sa.INTEGER(), nullable=False),
        sa.Column("user_id", sa.Unicode(length=120), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["user.user_id"],
            name=op.f("fk_oauth2_code_user_id_user"),
            ondelete="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_oauth2_code")),
        sa.UniqueConstraint("code", name=op.f("uq_oauth2_code_code")),
    )
    op.create_table(
        "oauth2_token",
        sa.Column("client_id", sa.String(length=48), nullable=True),
        sa.Column("token_type", sa.String(length=40), nullable=True),
        sa.Column("access_token", sa.String(length=255), nullable=False),
        sa.Column("refresh_token", sa.String(length=255), nullable=True),
        sa.Column("scope", sa.Text(), nullable=True),
        sa.Column("revoked", sa.Boolean(), nullable=True),
        sa.Column("issued_at", sa.Integer(), nullable=False),
        sa.Column("expires_in", sa.Integer(), nullable=False),
        sa.Column("id", sa.INTEGER(), nullable=False),
        sa.Column("user_id", sa.Unicode(length=120), nullable=True),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["user.user_id"],
            name=op.f("fk_oauth2_token_user_id_user"),
            ondelete="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_oauth2_token")),
        sa.UniqueConstraint("access_token", name=op.f("uq_oauth2_token_access_token")),
    )

oauth2_code passes fine but oauth2_token fails with:

Naming convention including %(constraint_name)s token requires that constraint is explicitly named

However, the name convention seems to be fine. I just can't figure out what is wrong with table oauth2_token.

I tried changing the column access_token to token:

sa.Column("token", sa.String(length=255), nullable=False),
..
sa.UniqueConstraint("token", name=op.f("uq_oauth2_token_token"))

But I get the same.

Any idea is appreciated.

QLands
  • 2,424
  • 5
  • 30
  • 50

0 Answers0