pg_partman
                                
                                 pg_partman copied to clipboard
                                
                                    pg_partman copied to clipboard
                            
                            
                            
                        how to do IF NOT EXISTS ( SELECT partman.create_parent )
I'm adding SELECT partman.create_parent() function into a evolution file, which will be used to create tables. but if the partitions already exists it is throwing error, in production environment we can't use it like this. we want to make this function run only if there is no previous entry. Some thing like -> CREATE TABLE IF NOT EXISTS .....
Are you saying the partition configuration already exists in pg_partman? If that's the case, you'll probably need something that first checks the part_config table to see if it has an entry there before calling create_parent(). Could write your own custom function to do that.
Hey Thank You @keithf4 it worked for me
On PostgreSQL, I found the best way to do this is:
select partman.create_parent(
               p_parent_table => 'public.my_table',
               p_control => 'inserted_at',
               p_type => 'native', -- I'm using pg_partman 4.6.2
               p_interval=> '1 day'
       )
 where not exists(
     select parent_table
       from partman.part_config
     where parent_table = 'public.my_table'
                 )