CREATE TABLE idempotency_keys (
request_key text NOT NULL,
endpoint text NOT NULL,
request_fingerprint text NOT NULL,
status text NOT NULL DEFAULT 'in_progress'
CHECK (status IN ('in_progress', 'completed')),
module ConnectionHealth
extend ActiveSupport::Concern
def with_fresh_connection
conn = ActiveRecord::Base.connection
conn.verify! # pings and reconnects if the socket is dead
import csv
class _LineBuffer:
def __init__(self):
self._data = ""
class Current < ActiveSupport::CurrentAttributes
attribute :tenant, :request_id
def tenant=(tenant)
super
Rails.logger.tagged("tenant=#{tenant&.id}") if tenant
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
package export
import (
"encoding/csv"
"log"
"net/http"
class OverdueInvoicesQuery
def initialize(relation: Invoice.all, as_of: Time.current)
@relation = relation
@as_of = as_of
end
import { Pool } from "pg";
async function keyFor(pool: Pool, name: string): Promise<string> {
const { rows } = await pool.query<{ key: string }>(
"SELECT hashtextextended($1, 0) AS key",
[name]
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
class Order < ApplicationRecord
include TransactionalEnqueue
belongs_to :customer
has_many :line_items, dependent: :destroy
class CreateAuditLogs < ActiveRecord::Migration[7.1]
def change
create_table :audit_logs do |t|
t.references :auditable, polymorphic: true, null: false
t.string :actor
t.string :action, null: false
class CreateCustomerRevenueSummaries < ActiveRecord::Migration[7.0]
def change
create_view :customer_revenue_summaries, materialized: true, version: 1
add_index :customer_revenue_summaries,
:customer_id,