Sha256: e81b44c2be834f0b8780b455500717a5c3e8e925ba598e119a17e2f125e27f03

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "active_partition"
require "active_record"
require "byebug"
require "rails"
def reload!
  files = $LOADED_FEATURES.select { |feat| feat =~ /\/active_partition\// }
  files.each { |file| load file }
end

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

# Create test model
class OutgoingEvent < ActiveRecord::Base
  include ActivePartition::Partitionable
  self.primary_key = "id"
  self.partitioned_by = "created_at"
  self.partition_range = 1.day

  # You can choose 1 of the following 2 options
  self.retention_period = 1.month
  self.retention_partition_count = 3
end

class OutgoingEventsWebhook < ActiveRecord::Base
  include ActivePartition::Partitionable
  self.primary_key = "id"
  self.partitioned_by = "created_at"
  self.partition_range = 1.month
  self.partition_start_from = DateTime.new(2021, 1, 1)

  # You can choose 1 of the following 2 options
  self.retention_period = 1.month
  self.retention_partition_count = 3
end

OutgoingEvent.establish_connection(ENV["DATABASE_URL"])
OutgoingEventsWebhook.establish_connection(ENV["DATABASE_URL"])

if OutgoingEventsWebhook.partition_adapter == OutgoingEvent.partition_adapter
  puts "Violate the partition adapter constraint", OutgoingEventsWebhook.partition_adapter == OutgoingEvent.partition_adapter
  puts OutgoingEventsWebhook.partition_adapter
  puts OutgoingEvent.partition_adapter
end

if OutgoingEventsWebhook.partition_manager == OutgoingEvent.partition_manager
  puts "Violate the partition manager constraint"
  puts OutgoingEventsWebhook.partition_manager
  puts OutgoingEvent.partition_manager
end

require "irb"
IRB.start(__FILE__)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_partition-0.7.0 bin/console