I'm using alembic for database migration. And using sqlalchemy to connect to the database using python.
In alembic, we define table schema as the first version and this the actual one which creates the schema.
For example, I have given schema like this in my first version of alembic.
op.create_table(
'my_table',
sa.Column('id', sa.String(10), primary_key=True),
sa.Column('mail', sa.String(20), unique=True)
)
Now, lets come to sqlalchemy part. Inside my python project, I have a database connection file, where I have created user table like this.
class CompanyInfo(Base):
__tablename__ = 'my_table'
id = Column(String(10), primary_key=False)
name = Column(String(20), unique=False)
Here, Alembic is the first thing which is connecting to the database and creating tables. So how does it matter whether I specify primary_key, unique constraint or nullable=T/F values inside my python class?
My question is only about constraints not on data types and it's length.