class AddSlugToPosts < ActiveRecord::Migration[7.1]
def change
add_column :posts, :slug, :string, null: false
add_index :posts, :slug, unique: true
end
end
namespace :cleanup do
desc "Enqueue a job to purge expired sessions"
task expired_sessions: :environment do
job = ExpiredSessionCleanupJob.perform_later
Rails.logger.info("[cleanup:expired_sessions] enqueued job #{job.job_id}")
end
class AddSoftDeleteToUsers < ActiveRecord::Migration[7.1]
def change
add_column :users, :deleted_at, :datetime
add_index :users, :deleted_at, where: "deleted_at IS NULL", name: "index_users_on_live"
class AddSlugToArticles < ActiveRecord::Migration[7.1]
def change
add_column :articles, :slug, :string
add_index :articles, :slug, unique: true
reversible do |dir|
class Article < ApplicationRecord
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
scope :published, -> { where.not(published_at: nil) }
module QueryBudget
class Counter
IGNORED = %w[SCHEMA CACHE TRANSACTION].freeze
attr_reader :count
class AddSearchVectorToArticles < ActiveRecord::Migration[7.1]
def up
execute <<~SQL
ALTER TABLE articles
ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (
CREATE TABLE events (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
source text NOT NULL,
external_id text NOT NULL,
payload jsonb NOT NULL,
occurred_at timestamptz NOT NULL,
class Task < ApplicationRecord
POSITION_GAP = 1024
belongs_to :board
scope :ordered, -> { order(:position) }
class Reminder < ApplicationRecord
belongs_to :user
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone::MAPPING.values }
validates :local_time, presence: true
package store
import (
"context"
"github.com/jackc/pgx/v5"
class BatchLoader {
constructor(batchFn, { cacheKeyFn = (k) => k } = {}) {
this.batchFn = batchFn;
this.cacheKeyFn = cacheKeyFn;
this.cache = new Map();
this.queue = [];