Skill站外收录 @skilllib/skill-2014279378627145731
local-env
支持本地开发环境中的数据库操作与测试数据配置,包括执行任意 SQL 查询、为组织或岗位模拟支付状态、重置测试数据、调整岗位生命周期状态,以及通过代码和数据库探查快速定位表结构与枚举值。
数据库 AI 技能
Skills.MD
# Local Environment Management
Help with local development environment tasks for daily-api.
## Database Access
PostgreSQL runs locally via Docker in a k8s container.
### Finding the Container
```bash
docker ps --format "table {{.Names}}" | grep "k8s_app_postgres"
```
### Running Queries
```bash
docker exec <CONTAINER_NAME> psql -U postgres -d api -c "YOUR SQL QUERY"
```
For multi-line queries:
```bash
docker exec <CONTAINER_NAME> psql -U postgres -d api <<'EOF'
SELECT * FROM users LIMIT 1;
EOF
```
## Fake Payment Setup
Payment status for opportunities is tracked on the **Organization** level via `recruiterSubscriptionFlags`. Opportunities also store subscription info in their `flags` column.
### Organization Subscription Fields
| Field | Description |
|-------|-------------|
| `status` | Must be `'active'` for payment validation to pass |
| `provider` | Use `'paddle'` |
| `items[].quantity` | Number of opportunity "seats" available |
| `items[].priceId` | Price ID that opportunities reference |
### Opportunity Flags Fields
| Field | Description |
|-------|-------------|
| `plan` | Must match a `priceId` from the org's subscription items |
| `batchSize` | Number of candidates per batch |
### Fake Payment for Organization
```sql
UPDATE organization
SET "recruiterSubscriptionFlags" = jsonb_build_object(
'status', 'active',
'provider', 'paddle',
'subscriptionId', 'fake_sub_123',
'createdAt', now(),
'updatedAt', now(),
'items', jsonb_build_array(
jsonb_build_object('priceId', 'pri_fake_123', 'quantity', 5)
)
)
WHERE id = 'ORGANIZATION_ID';
```
Reset: `UPDATE organization SET "recruiterSubscriptionFlags" = '{}' WHERE id = 'ORGANIZATION_ID';`
### Fake Payment for Opportunity
Requires updating both the organization AND the opportunity:
```sql
-- Step 1: Update organization subscription
UPDATE organization
SET "recruiterSubscriptionFlags" = jsonb_build_object(
'status', 'active',
'provider', 'paddle',
'subscriptionId', 'fake_sub_123',
'createdAt', now(),
'updatedAt', now(),
'items', jsonb_build_array(
jsonb_build_object('priceId', 'pri_fake_123', 'quantity', 5)
)
)
WHERE id = (SELECT "organizationId" FROM opportunity WHERE id = 'OPPORTUNITY_ID');
-- Step 2: Update opportunity flags
UPDATE opportunity
SET flags = flags || jsonb_build_object(
'plan', 'pri_fake_123',
'batchSize', 50
)
WHERE id = 'OPPORTUNITY_ID';
```
Reset:
```sql
UPDATE organization SET "recruiterSubscriptionFlags" = '{}'
WHERE id = (SELECT "organizationId" FROM opportunity WHERE id = 'OPPORTUNITY_ID');
UPDATE opportunity SET flags = flags - 'plan' - 'batchSize'
WHERE id = 'OPPORTUNITY_ID';
```
## Opportunity State Management
The `opportunity` table uses a `state` column (integer) to track lifecycle status. Values come from `OpportunityState` enum in `@dailydotdev/schema`.
### OpportunityState Values
| Value | Name | Description |
|-------|------|-------------|
| 0 | UNSPECIFIED | Default/unset |
| 1 | DRAFT | Not yet published |
| 2 | LIVE | Active and visible |
| 3 | CLOSED | No longer active |
| 4 | IN_REVIEW | Pending review |
### Update Opportunity State
```sql
-- Set to LIVE
UPDATE opportunity SET state = 2 WHERE id = 'OPPORTUNITY_ID' RETURNING id, state, title;
-- Set to DRAFT
UPDATE opportunity SET state = 1 WHERE id = 'OPPORTUNITY_ID' RETURNING id, state, title;
-- Set to CLOSED
UPDATE opportunity SET state = 3 WHERE id = 'OPPORTUNITY_ID' RETURNING id, state, title;
-- Set to IN_REVIEW
UPDATE opportunity SET state = 4 WHERE id = 'OPPORTUNITY_ID' RETURNING id, state, title;
```
## Instructions
When the user asks for local environment help:
1. **For SQL queries**: First find the postgres container, then execute via docker exec
2. **For fake payments**: Determine if they're providing an opportunity ID or organization ID, run the appropriate SQL
3. **Always verify**: After changes, run a SELECT to confirm
4. **Ask if unclear**: If the request is ambiguous, ask clarifying questions
Common requests:
- "Set up fake payment for opportunity X" → Run both org and opportunity updates
- "Set up fake payment for org X" → Run only org update
- "Run SQL: ..." → Execute via docker
- "Reset payment for X" → Run reset queries
- "Check subscription for X" → Query and display current state
- "Update opp X to live/draft/closed" → Update opportunity state
## Discovering Schema Information
When handling requests not covered in this skill, use these techniques to discover the correct schema:
### 1. Check Entity Definitions
Entity files define column names and types:
```bash
# Find the entity file
grep -r "TableName" src/entity/ --include="*.ts"
# Read the entity to see column definitions
```
Key location: `src/entity/` - TypeORM entities with `@Column` decorators show actual DB column names.
### 2. Find Enum Values
Many columns use integer enums from `@dailydotdev/schema`. To find enum values:
```bash
# Search for enum usage in codebase
grep -r "EnumName\." src/ --include="*.ts" | head -20
# Find enum definition in schema package
grep -r "EnumName" node_modules/@dailydotdev/schema/dist/ --include="*.d.ts"
```
Common enum locations: `node_modules/@dailydotdev/schema/dist/daily-api/*_pb.d.ts`
### 3. Query Existing Data
When unsure about column names or values:
```sql
-- Check table structure
\d tablename
-- See existing values
SELECT DISTINCT column_name FROM tablename LIMIT 10;
-- Inspect a specific row
SELECT * FROM tablename WHERE id = 'xxx' LIMIT 1;
```
### 4. Common Gotchas
- **Column naming**: Entity property names may differ from DB columns (e.g., `state` not `status`)
- **Integer enums**: Many "status" fields are integers, not strings - find the enum definition
- **JSONB fields**: Use `jsonb_build_object()` for updates, `->` or `->>` for queries
- **Quoted columns**: PostgreSQL requires double quotes for camelCase columns (e.g., `"organizationId"`)
## Continuous Improvement
This skill should evolve over time. When you discover new local environment operations, common testing patterns, or useful queries:
1. **Add them to this file** - Update the SKILL.md with new sections or examples
2. **Keep it practical** - Focus on operations that are frequently needed
3. **Document the why** - Explain what fields mean and why certain values are used
If a user asks for something not covered here, help them and then offer to add it to this skill for future use.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「local-env」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次