Skip to main content

Overview

The requests table stores feature requests and user feedback items. Each request has a title, description, status, and can be associated with areas, followers, and related links.

Fields

id
uuid
required
Primary key. Auto-generated UUID for the request.
title
text
required
The title of the feature request.
description
text
required
Detailed description of the feature request.
status
request_status
required
Current status of the request. See Enums for possible values. Default: open.
creator
uuid
Foreign key reference to users.id. The user who created the request.
createdAt
timestamp
required
Timestamp with timezone when the request was created. Default: now().
updatedAt
timestamp
required
Timestamp with timezone when the request was last updated. Default: now().
slug
text
required
URL-friendly unique identifier for the request. Must be unique.
notes
text
Additional internal notes about the request.
areaIds
varchar(36)[]
required
Array of area IDs associated with this request. Default: [].
Array of external URLs related to this request. Default: [].
linearUrl
text
URL to the associated Linear issue, if any.
followers
uuid[]
required
Array of user IDs following this request. Default: [].
Foreign key reference to another request in requests.id. Links related requests together.
metadata
jsonb
Additional metadata stored as JSON.

Enums

request_status

The status field uses the request_status enum with the following values:
  • open - Request is active and being considered
  • shipped - Feature has been implemented and released
  • deprioritized - Request has been deprioritized

Relationships

Belongs to

  • User (creator): requests.creatorusers.id
  • Related Request (self-referential): requests.relatedRequestIdrequests.id

Has many

  • Feedback: Multiple feedback items can reference a single request via feedback.requestId

Indexes

requests_slug_key
unique
Unique constraint on the slug field.
requests_creator_idx
index
B-tree index on creator field for faster queries by creator.
requests_updated_at_idx
index
B-tree index on updatedAt field for sorting by modification time.
requests_area_ids_idx
gin
GIN index on areaIds array for efficient array containment queries.
GIN index on relatedLinks array for efficient array searches.
requests_followers_idx
gin
GIN index on followers array for efficient follower lookups.
B-tree index on relatedRequestId for related request queries.

Example queries

Query all open requests

import { db } from './db';
import { requests } from './schema';
import { eq } from 'drizzle-orm';

const openRequests = await db.query.requests.findMany({
  where: eq(requests.status, 'open'),
  orderBy: (requests, { desc }) => [desc(requests.updatedAt)],
});

Get request with creator and feedback

import { db } from './db';
import { requests } from './schema';
import { eq } from 'drizzle-orm';

const request = await db.query.requests.findFirst({
  where: eq(requests.slug, 'my-feature-request'),
  with: {
    user: true,
    feedback: {
      with: {
        user: true,
        account: true,
      },
    },
  },
});

Find requests by area

import { db } from './db';
import { requests } from './schema';
import { arrayContains } from 'drizzle-orm';

const requestsInArea = await db.query.requests.findMany({
  where: arrayContains(requests.areaIds, ['area-id-here']),
});

Get requests followed by a user

import { db } from './db';
import { requests } from './schema';
import { arrayContains } from 'drizzle-orm';

const userId = 'user-uuid-here';
const followedRequests = await db.query.requests.findMany({
  where: arrayContains(requests.followers, [userId]),
});

Create a new request

import { db } from './db';
import { requests } from './schema';

const newRequest = await db.insert(requests).values({
  title: 'Add dark mode support',
  description: 'Users want a dark mode option for better readability',
  slug: 'add-dark-mode-support',
  creator: 'user-uuid-here',
  areaIds: ['ui-area-id'],
  status: 'open',
}).returning();

Build docs developers (and LLMs) love