-- Step 1: add the column nullable, no default.
-- Catalog-only change in Postgres 11+, returns instantly.
ALTER TABLE orders
ADD COLUMN currency text;
-- Optional: keep the lock attempt bounded so a long-running
package com.shop.payments.messaging;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public record PaymentEvent(
import { Injectable } from '@nestjs/common';
type Completed = { status: 'completed'; statusCode: number; body: unknown; expiresAt: number };
type InFlight = { status: 'in-flight'; startedAt: number };
type Record = Completed | InFlight;
package middleware
import (
"net/http"
"sync/atomic"
)
package sse
type Broker struct {
subscribers map[chan []byte]struct{}
subscribe chan chan []byte
unsubscribe chan chan []byte
import {
Column,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
VersionColumn,
import threading
class MinuteRingBuffer:
def __init__(self, window_minutes=15):
if window_minutes < 1:
const STORAGE_KEY = "auth.refreshToken";
let accessToken = null;
let refreshToken = localStorage.getItem(STORAGE_KEY);
const listeners = new Set();
class LeaderboardCache
TOP_KEY = "leaderboard:top".freeze
STATS_KEY = "leaderboard:stats".freeze
def top_players
Rails.cache.fetch(TOP_KEY, expires_in: 5.minutes, race_condition_ttl: 15.seconds) do
class CreateWebhookEvents < ActiveRecord::Migration[7.1]
def change
create_table :webhook_events do |t|
t.string :event_id, null: false
t.string :source, null: false, default: "stripe"
t.string :event_type, null: false
class CreateOutboxEvents < ActiveRecord::Migration[7.1]
def change
create_table :outbox_events do |t|
t.string :event_type, null: false
t.string :aggregate_type, null: false
t.string :aggregate_id, null: false
import { Prisma, PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
type TxClient = Prisma.TransactionClient;