lib/partitioned/partitioned_base/sql_adapter.rb in partitioned-1.1.10 vs lib/partitioned/partitioned_base/sql_adapter.rb in partitioned-1.1.11
- old
+ new
@@ -43,10 +43,19 @@
def create_partition_schema(*partition_key_values)
create_schema(configurator.schema_name, :unless_exists => true)
end
#
+ # Child tables whose parent table is 'foos', typically exist in a schema named foos_partitions.
+ #
+ # *partition_key_values are needed here to support the use of multiple schemas to keep tables in.
+ #
+ def drop_partition_schema(*partition_key_values)
+ drop_schema(configurator.schema_name, :cascade => true)
+ end
+
+ #
# Does a specific child partition exist.
#
def partition_exists?(*partition_key_values)
return find(:first,
:from => "pg_tables",
@@ -113,9 +122,21 @@
ON INSERT TO #{configurator.table_name(*partition_key_values)}
DO INSTEAD
(
SELECT always_fail_on_insert('#{configurator.table_name(*partition_key_values)}')
)
+ SQL
+ execute(sql)
+ end
+
+ #
+ # Used to drop the parent table rule.
+ #
+ def remove_parent_table_rules(*partition_key_values)
+ insert_redirector_name = parent_table_rule_name("insert", "redirector", *partition_key_values)
+ sql = <<-SQL
+ DROP RULE #{insert_redirector_name}
+ ON INSERT CASCADE
SQL
execute(sql)
end
#