AGENT SKILL

schema-separation-orm-control

Schema Separation for ORM/Scaffolding Control

License 许可
MIT
最近更新
2026-11-14
Stars
★ 18
Forks
6

01 前言 Front Matter

name
schema-separation-orm-control
metadata
{ "original-index": 18, "short-description": "Schema Separation for ORM/Scaffolding Control" }
description
Schema Separation for ORM/Scaffolding Control

02 资源文件 1

03 SKILL.md 正文

Schema Separation for ORM/Scaffolding Control

What

Moving internal database objects (partition children, helper tables, maintenance artifacts) into a separate schema so that ORM tools (Entity Framework, Npgsql, Prisma) only scaffold the intended application tables.

Why

ORMs like Entity Framework discover tables via information_schema.tables. If partition children (e.g., AppointmentInfo_2024, AppointmentInfo_2025) live in the public schema alongside the parent table, EF will scaffold them as separate entities -- creating confusion, compilation errors, and bloated models.

Moving them to a partitions schema removes them from the ORM's discovery path while keeping them fully functional (PostgreSQL resolves partition routing regardless of schema).

How

Step 1: Create the target schema

CREATE SCHEMA IF NOT EXISTS partitions;

Step 2: Move the partition children

ALTER TABLE public."AppointmentInfo_2024"
    SET SCHEMA partitions;

ALTER TABLE public."AppointmentInfo_2025"
    SET SCHEMA partitions;

Step 3: Verify partition routing still works

-- Insert should still route to the correct partition
INSERT INTO public."AppointmentInfo" ("CreatedDate", ...)
VALUES ('2025-06-15', ...);

-- Query should still find data across all partitions
SELECT * FROM public."AppointmentInfo"
WHERE "CreatedDate" >= '2025-01-01';

Step 4: Update EF scaffolding command

# Scaffold only public schema
dotnet ef dbcontext scaffold ... --schema public

Schema Candidates

Object Type Move To Reason
Partition children partitions Hide from ORM discovery
Maintenance procedures maintenance Separate ops from app code
Monitoring views monitoring Separate observability layer
Audit triggers/functions audit Clean separation of concerns

When to Use

  • After implementing table partitioning
  • When ORM scaffolding picks up unwanted objects
  • When separating operational concerns from application concerns

Where We Used It

  • ****: Moved partition children from public to partitions schema so EF/Npgsql scaffolding only discovers parent tables

References

  • PostgreSQL Best Practices -- see Audit Finding #8 (Everything in public schema) and "Database naming conventions" (Schemas section)

Gotchas

  • SET SCHEMA acquires AccessExclusiveLock -- brief but blocking
  • Indexes, constraints, and triggers move with the table automatically
  • Foreign keys referencing the moved table remain valid (OID-based, not name-based)
  • Sequences do NOT automatically move -- check if any need to follow
  • Ensure the ORM connection's search_path does NOT include the new schema

*Category: Strategy | Origin: *

04 同仓库更多 Skills

CarlosCaPe
CarlosCaPe/octorato

yeet

Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).

★ 18
CarlosCaPe
CarlosCaPe/octorato

wrangler

Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

★ 18
CarlosCaPe
CarlosCaPe/octorato

workspace-skill-discovery

Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude/skills/ or skills/ in any repo) are never missed.

★ 18
CarlosCaPe
CarlosCaPe/octorato

workers-best-practices

Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

★ 18
CarlosCaPe
CarlosCaPe/octorato

winui-app

Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.

★ 18
CarlosCaPe
CarlosCaPe/octorato

windows-brain-script-portability

Scripts in ~/.claude/scripts/ that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.

★ 18