Helllo.
I have a model, with specified __tablename__ = 'base_table'.
In postgresql, the table has trigger, which executes before each insert: it
creates partition for current month (if it not exist yet), specifies
"INHERITS (base_table)" for new partition and insert data into it.
Is there any way to autodetect table inheritance and generate migration
script for it?
If autodetection not working...
I can get list of inherited tables with such query:
SELECT child.relname, parent.relname
FROM pg_catalog.pg_inherits
INNER JOIN pg_catalog.pg_class as child ON (pg_inherits.inhrelid =
child.oid)
INNER JOIN pg_catalog.pg_class as parent ON (pg_inherits.inhparent =
parent.oid)
WHERE inhparent = 'base_table'::regclass;
Returned names can be specified as parameter "only" in "reflect()" method
of MetaData instance. Can I specify target table for each table in metadata
for migration?
I found just such solution:
for table_name in inherit_table_names:
meta_data.tables[table_name].name = "base_table"
Is my solution safe?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.