Open ddelemeny opened 9 years ago
Hi,
Great idea. Unfortunately I don't have time to do this right now, but if you're able to implement this feature and send a pull request with tests, I'll happily merge it.
Thanks
Hi again, I have a draft implementation referenced above. It passes existing tests, but I don't have implemented specific test cases yet.
A side comment though : the "formatted getattr" way of calling functions to build sql looks a bit clumsy and possibly hard to maintain/extend, and my implementation will likely conflict with other forks out there who assume 'get_{0}_partition_function' (see for example https://github.com/dimoha/architect/blob/master/architect/databases/postgresql/partition.py)
So, what do you think ?
Hi,
Sorry, I missed your comment somehow, shame on me.
As for the question, I don't think that the "formatted getattr" way of calling functions to build sql looks a bit clumsy and possibly hard to maintain/extend
, I think opposite, it's much more flexible than, for example, having a set of if statements building sql. But if you have a better idea, I'm ready to listen.
Speaking about your implementation, it's ok, but I don't see the suggested optionally make it available as API on the Django model
implemented. Also it should be implemented for all ORM backends and not just the Django one.
Hello,
I'm happily using architect with django and there's a use-case I'd love to see simplified.
I'm partitioning a table on a date field by month, and the insert pattern on this table is the following : Every month, I use a python/django/psycopg script to COPY a lot of rows with the date field set to Y-m-01. I could totally preempt table creation and load that data directly to the partition table, thus avoiding the overhead.
The requested feature is : Extract a partition creation function from the _insert_child trigger, and optionally make it available as API on the Django model.
What do you think ?