1. Michael Bayer
  2. alembic

Issues

Issue #81 resolved

op.create_table emit_events arg is an invalid argument

Robert Kopaczewski
created an issue

According to docs, emit_events=True should imply that before_create and after_create events will be emitted.

That's not the case.

op.create_table('role',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=80), nullable=True),
sa.Column('description', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id'),
emit_events=True
)

Results in: TypeError: Invalid argument(s) for Table: ['emit_events']

Is there some other way to create custom indexes with alembic?

Comments (2)

  1. Michael Bayer repo owner

    that documentation note is apparently an inadvertent checkin, is removed in 894afbf83c3aba783519358ac82e9c7114282701.

    The feature it discusses is more related to PG's ENUM type, which can now be created directly now. Alembic fires off the before_create() and after_create() events for CreateTable in all cases. However, using these kinds of events directly in an Alembic script just makes the script more complicated, as an alembic script is just a straight list of DDL to emit, you just add any additional DDL inline.

    The term "custom indexes" can mean several things. If it means, you just want to create an index explicitly, you just use op.create_index(). If it means, you want to create an index that makes use of some unsupported syntax, like a Postgresql functional index, you write out the "CREATE INDEX" statement as a string and invoke it via op.execute().

  2. Log in to comment