ワンクリックで
add-migration
Create a new database migration with timestamp-based naming. Use when adding schema changes.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create a new database migration with timestamp-based naming. Use when adding schema changes.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Keep the Threa Pi remote-control extension in `extensions/pi-remote/` aligned with the current Pi extension API and Threa bot-runtime public API. Use when asked to update, verify, sync, or troubleshoot the Pi remote plugin, `/remote-control`, or `threa-remote.ts`.
Create a well-structured pull request with proper description, design decisions, and file changes. Use when asked to create a PR, open a PR, or submit changes for review.
Call Threa's public REST API (send/list/search/update/delete messages, list streams/users/members, search memos/attachments) with curl or a Bun script. Use when asked to post messages to a stream, seed a stream with test data, drive the API from automation, dedupe by metadata, inspect a production workspace (streams, messages, members) for troubleshooting, or otherwise hit https://staging.threa.io / https://app.threa.io endpoints with an API key. Reads from production should use the read-only prod key.
Rewrite user-facing copy (marketing pages, docs, headings, UI microcopy, READMEs, PR descriptions) to strip AI-slop and salesy tone, leaving plain, understated, factual prose. Use when asked to "deslopify", "deslop", "remove the AI slop", "make this less salesy/less AI-sounding", "make the copy plainer", or when reviewing copy for slop tells.
Run multi-perspective code review on a PR or the local branch
Write a session handover doc for the next agent picking up this line of work. Use when asked to "write a handover", "hand over", "handoff doc", or at the end of a session whose work continues in a future session.
| name | add-migration |
| description | Create a new database migration with timestamp-based naming. Use when adding schema changes. |
Create a new database migration file with proper timestamp-based naming to avoid conflicts when working in parallel.
Get the current local timestamp in YYYYMMDDHHmmss format:
date +%Y%m%d%H%M%S
This will output something like: 20260120154111
Migrations live in apps/backend/src/db/migrations/ and follow the naming convention:
YYYYMMDDHHmmss_descriptive_name.sql
Example: 20260120154111_add_user_preferences.sql
File naming guidelines:
add_table, drop_column, add_index)Migrations should be idempotent where possible and include comments explaining the change:
-- Add user preferences table
-- This allows users to customize their workspace experience
CREATE TABLE IF NOT EXISTS user_preferences (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
workspace_id TEXT NOT NULL,
preferences JSONB NOT NULL DEFAULT '{}',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_user_preferences_user_workspace
ON user_preferences(user_id, workspace_id);
# Apply the migration
cd apps/backend
bun run db:migrate
# Verify it worked
bun run db:status
DO:
CREATE TABLE IF NOT EXISTS for new tablesCREATE INDEX IF NOT EXISTS for new indexesDON'T:
CLAUDE.md -> Invariant Playbook -> Data Model and Persistence Safety, INV-17)Add a column:
-- Add display_name to streams
ALTER TABLE streams
ADD COLUMN IF NOT EXISTS display_name TEXT;
Drop a column:
-- Remove unused legacy_id column
ALTER TABLE users
DROP COLUMN IF EXISTS legacy_id;
Add an index:
-- Speed up stream lookups by workspace
CREATE INDEX IF NOT EXISTS idx_streams_workspace
ON streams(workspace_id);
Create a table:
-- Create memos table for GAM system
CREATE TABLE IF NOT EXISTS memos (
id TEXT PRIMARY KEY,
workspace_id TEXT NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
Timestamp collision: If you somehow generate the same timestamp as an existing migration:
# Wait one second and generate a new timestamp
sleep 1 && date +%Y%m%d%H%M%S
Migration fails:
psql postgresql://threa:threa@localhost:5454/threa
# Manually undo the changes
Need to undo a migration:
Since migrations are immutable once committed (INV-17; CLAUDE.md -> Invariant Playbook -> Data Model and Persistence Safety), create a new migration that reverts the changes:
date +%Y%m%d%H%M%S # Get new timestamp
# Create: 20260120160000_revert_user_preferences.sql
Adding a new feature table:
# Generate timestamp
TIMESTAMP=$(date +%Y%m%d%H%M%S)
# Create migration file
touch apps/backend/src/db/migrations/${TIMESTAMP}_add_reactions.sql
# Edit the file with your schema changes
# Then test it
cd apps/backend && bun run db:migrate
Adding an index for performance:
TIMESTAMP=$(date +%Y%m%d%H%M%S)
cat > apps/backend/src/db/migrations/${TIMESTAMP}_index_messages_stream.sql << 'EOF'
-- Add index for message queries by stream
-- Improves performance when loading stream history
CREATE INDEX IF NOT EXISTS idx_messages_stream_created
ON messages(stream_id, created_at DESC);
EOF
cd apps/backend && bun run db:migrate