Paritioned Table Migration

920 views
Skip to first unread message

Stephan Gerhard

unread,
Aug 29, 2019, 8:55:40 AM8/29/19
to sqlalchemy-alembic
Hi,

I am wondering whether it is possible to use Alembic to define a migration where I add a partitioned table - a feature that is supported in Postgres 12 - e.g. using range partitions.

How would I write this as an Alembic migration?

Thanks,
Stephan

Mike Bayer

unread,
Aug 29, 2019, 10:16:28 AM8/29/19
to sqlalchem...@googlegroups.com
you would use op.execute():

e.g.

def upgrade():
    op.execute(
            "CREATE TABLE data_values_4_10 PARTITION OF data_values "
            "FOR VALUES FROM (4) TO (10)"
    )





Thanks,
Stephan


--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.

Stephan Gerhard

unread,
Aug 29, 2019, 1:03:18 PM8/29/19
to sqlalchemy-alembic
Thanks!


Am Donnerstag, 29. August 2019 16:16:28 UTC+2 schrieb Mike Bayer:


On Thu, Aug 29, 2019, at 8:55 AM, Stephan Gerhard wrote:
Hi,

I am wondering whether it is possible to use Alembic to define a migration where I add a partitioned table - a feature that is supported in Postgres 12 - e.g. using range partitions.

How would I write this as an Alembic migration?

you would use op.execute():

e.g.

def upgrade():
    op.execute(
            "CREATE TABLE data_values_4_10 PARTITION OF data_values "
            "FOR VALUES FROM (4) TO (10)"
    )





Thanks,
Stephan


--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages