# Rank

> Fractional rank keys: rank_between, move() for every config.recordTypes entry with a rank column (through the caller's policies and any state-machine trigger), and a rebalance job.

- Category: Database primitives
- Module: `rank`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/rank
- Page: https://bettersupabase.com/blocks/rank

## Install

```bash
npx better-supabase add rank
```

The command also installs `updated-at`, `memberships`, `permissions`, `subjects`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by rank; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    subjects: {},
    // Modes: "managed", "custom". The default is "managed".
    rank: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/rank`.

## Related blocks

Requires: [permissions](https://bettersupabase.com/blocks/permissions.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

Works with: [queue](https://bettersupabase.com/blocks/queue.md)

## Recipes

- [Work item board](https://bettersupabase.com/recipes/work-item-board.md): Work items in state columns, ordered by rank and moved through allowed transitions.
- [Record board](https://bettersupabase.com/recipes/record-board.md): An app table as a board with a column per option value, where dragging a card writes the value and its rank.
