Creating and dropping partition in PostgreSQL "on the fly"?
Usually it is the best thing to create partitions for the data you expect ahead of time and handle the error when unexpected data arrive.
There is also the option of a default partition that receives data that belongs into no other partition, but that is usually only a good idea if you have a fixed number of partitions, because conflicting data in the default partition prevents creation of a new partition.