summaryrefslogtreecommitdiff
path: root/app/models/loose_foreign_keys/deleted_record.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/loose_foreign_keys/deleted_record.rb')
-rw-r--r--app/models/loose_foreign_keys/deleted_record.rb37
1 files changed, 17 insertions, 20 deletions
diff --git a/app/models/loose_foreign_keys/deleted_record.rb b/app/models/loose_foreign_keys/deleted_record.rb
index 6dfd6ea2aae..94444f4b6d3 100644
--- a/app/models/loose_foreign_keys/deleted_record.rb
+++ b/app/models/loose_foreign_keys/deleted_record.rb
@@ -9,26 +9,23 @@ class LooseForeignKeys::DeletedRecord < Gitlab::Database::SharedModel
self.ignored_columns = %i[partition]
partitioned_by :partition, strategy: :sliding_list,
- next_partition_if: -> (active_partition) do
- return false if Feature.disabled?(:lfk_automatic_partition_creation)
-
- oldest_record_in_partition = LooseForeignKeys::DeletedRecord
- .select(:id, :created_at)
- .for_partition(active_partition)
- .order(:id)
- .limit(1)
- .take
-
- oldest_record_in_partition.present? && oldest_record_in_partition.created_at < PARTITION_DURATION.ago
- end,
- detach_partition_if: -> (partition) do
- return false if Feature.disabled?(:lfk_automatic_partition_dropping)
-
- !LooseForeignKeys::DeletedRecord
- .for_partition(partition)
- .status_pending
- .exists?
- end
+ next_partition_if: -> (active_partition) do
+ oldest_record_in_partition = LooseForeignKeys::DeletedRecord
+ .select(:id, :created_at)
+ .for_partition(active_partition)
+ .order(:id)
+ .limit(1)
+ .take
+
+ oldest_record_in_partition.present? &&
+ oldest_record_in_partition.created_at < PARTITION_DURATION.ago
+ end,
+ detach_partition_if: -> (partition) do
+ !LooseForeignKeys::DeletedRecord
+ .for_partition(partition)
+ .status_pending
+ .exists?
+ end
scope :for_table, -> (table) { where(fully_qualified_table_name: table) }
scope :for_partition, -> (partition) { where(partition: partition) }