Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create table does not create unique keys and indexes #580

Open
YuriFontella opened this issue Jan 20, 2024 · 0 comments
Open

create table does not create unique keys and indexes #580

YuriFontella opened this issue Jan 20, 2024 · 0 comments

Comments

@YuriFontella
Copy link

By defining the index on the columns and as a unique key, the table is created with the CreateTable function, but the keys are not.

users = Table(
    'users',
    metadata,
    Column('id', Integer, primary_key=True),
    Column('name', String(length=255)),
    Column('email', String(length=255), unique=True, index=True)
)
for table in metadata.tables.values():
    schema = sqlalchemy.schema.CreateTable(table, if_not_exists=True)
    query = schema.compile(dialect=postgresql.dialect())

    await database.execute(query=str(query))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant