Support for PostgreSQL partitioned tables
avaly opened this issue · 0 comments
avaly commented
PostgreSQL supports native table partitioning. The intended way of using partitioned tables is to read from/update the main table.
When running pg-schema-cli
on a database with a partitioned table, the output only contains the partitions of that table, but not the table itself:
Excerpt from the generated index.ts
:
interface DatabaseSchema {
posts_p0: { record: PostsP0Record; insert: PostsP0InsertRecord };
posts_p1: { record: PostsP1Record; insert: PostsP1InsertRecord };
posts_p2: { record: PostsP2Record; insert: PostsP2InsertRecord };
Because the main table posts
does not show up in the generated TS files or the generated schema.json
file, the pg-typed
package does not return a table from tables()
for the main posts
table.
So, we can only interact with the individual partition tables through pg-typed
.
The only way to interact with the main partitioned table is through raw SQL queries.