I'm building an application that needs to be deployed several times, with a relatively well organized data model. A table needs to be configured for each deployment with a small number of additional fields, different each time. Performance is not an issue, as we're talking about a few hundreds of rows and a dozen of additional fields.
I'm inclined to keep a unique, generic data model, and thus I'm trying (maybe naively) to use something like an EAV model for that table as such:
user: table has common fieldsuser_data: user_id, field_id, field_valuefield: id, field_name, field_type
My intention was then to crosstab the user_data table to have a table such as user_id, field1, field2, field3, ... that I could then join to my user table.
However, crosstab requires a custom type for the output of the pivot, with all field names and types that will go in column. I have all the information stored in the field table.
My question is then: can I create a custom type dynamically in PostgreSQL, from the information I store in my field table?