- When starting a fresh project with Postgres 11 or higher, you can disable template tables and enable primary key constraints on partitioned tables:
config.create_template_tables
now governs whether template tables are created by default (defaults true).config.create_with_primary_key
passed down primary key options to CREATE TABLE, including support for composite primary keys
create_hash_partition
,create_hash_partition_of
, andattach_hash_partition
methods provide support for Hash partitionscreate_default_partition_of
andattach_default_partition
allows adding of default partitions to range and list partitioned tables
create_x_partition_of
methods now supportpartition_type
andpartition_key
, which may be supplied to create a partitioned child table.- Use
create_x_partition_of
with the child table name to add a partition to your subpartition - Template tables are supported in that nested subpartitions will inherit from the top-level ancestor's template table, if found
- Use
- The
partitions
command now accepts aninclude_subpartitions:
option which defaults to false for backward compatibility- Use
config.include_subpartitions_in_partition_list = true
to override the default
- Use
- Use this new adapter method in migrations to add an index on all partitions and subpartitions automatically
- This method supports
algorithm: :concurrently
to perform uptime operations, so even when using Postgres 11+ it is needed to avoid table locks. - If you have many partitions, use the optional
in_threads:
option to parallelize index creation via theparallel
gem
- Added adapter methods
partitions_for_table_name
,parent_for_table_name
, andtable_partitioned?
to assist automating partition management, especially where subpartitions are involved