production:
primary:
adapter: postgresql
database: app_production
username: app
password: <%= ENV["PRIMARY_DB_PASSWORD"] %>
class AddSoftDeleteToDocuments < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_column :documents, :marked_for_deletion_at, :datetime, null: true
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 5_000 }
module ConnectionHealth
extend ActiveSupport::Concern
def with_fresh_connection
conn = ActiveRecord::Base.connection
conn.verify! # pings and reconnects if the socket is dead
class Order < ApplicationRecord
has_many :line_items, dependent: :destroy, inverse_of: :order
accepts_nested_attributes_for :line_items,
reject_if: :all_blank,
allow_destroy: true
class Current < ActiveSupport::CurrentAttributes
attribute :tenant, :request_id
def tenant=(tenant)
super
Rails.logger.tagged("tenant=#{tenant&.id}") if tenant
module Cacheable
extend ActiveSupport::Concern
def cache_query(prefix, scope, expires_in: 15.minutes)
key = [prefix, cache_version_token(scope)].join("/")
class CreateAuditLogs < ActiveRecord::Migration[7.1]
def change
create_table :audit_logs do |t|
t.references :auditable, polymorphic: true, null: false
t.references :user, null: true, foreign_key: true
t.string :action, null: false
class Order < ApplicationRecord
has_many :line_items, inverse_of: :order, dependent: :destroy
accepts_nested_attributes_for :line_items,
allow_destroy: true,
reject_if: ->(attrs) { attrs["product_id"].blank? && attrs["quantity"].blank? }
class OverdueInvoicesQuery
def initialize(relation: Invoice.all, as_of: Time.current)
@relation = relation
@as_of = as_of
end
class Order < ApplicationRecord
include TransactionalEnqueue
belongs_to :customer
has_many :line_items, dependent: :destroy
module DomainEvents
class Registry
def initialize
@subscribers = Hash.new { |h, k| h[k] = [] }
end