Describe the bug
I had a table which didn't has primary_key previously, and later I wanted to add a primary_key column, so I used add_column function as follows, but the primary_key was not added. Thanks for your attention.
op.add_column("collection1", sa.Column("id", sa.String, primary_key=True))
To Reproduce
A minimal example is as follows:
"""interaction test Revision ID: 3143332ab75e Revises: 63e25a7c5c04 Create Date: 2023-04-27 09:48:23.650748 """ from alembic import op import sqlalchemy as sa revision = '3143332ab75e' down_revision = '63e25a7c5c04' branch_labels = None depends_on = None def upgrade(): op.create_table( "collection1", sa.Column("status", sa.Integer, nullable=False, server_default="1"), sa.Column("created_at", sa.Integer, server_default=sa.text("extract(epoch from now())::int")), sa.Column("updated_at", sa.Integer, server_default=sa.text("extract(epoch from now())::int")), sa.Column("deleted_at", sa.Integer, server_default=sa.text("0")), ) op.add_column("collection1", sa.Column("id", sa.String, primary_key=True)) def downgrade(): op.drop_table("collection1")
Versions.
- OS: macOS
- Python: 3.10
- Alembic: 1.8.0
- SQLAlchemy: 1.3.6
- Database: PostgresSQL 14.7
- DBAPI: May be PEP 249 Python Database API Specification v2.0? I don't know, sorry.