Database Management
Polecat uses Weasel.SqlServer for all database schema management. Tables are automatically created and updated as needed.
Because every Polecat table is a Weasel schema object, you get the same set of choices every Critter Stack store has: let Polecat migrate lazily at runtime, apply the schema once at startup, run the migration as a deployment step with db-apply or resources setup, or hand db-patch scripts to a DBA. See Schema Migrations for the comparison, and the Weasel documentation for the migration engine and AutoCreate policy and the command line tools.
Auto-Create Modes
Control schema management behavior via StoreOptions.AutoCreateSchemaObjects:
| Mode | Behavior |
|---|---|
CreateOrUpdate (default) | Creates new tables, and alters existing tables to match the configuration: adds new columns, and drops columns and indexes the configuration no longer declares |
CreateOnly | Only creates new tables, never modifies existing ones |
None | No automatic schema management at runtime. An explicit db-apply or resources setup still migrates |
These are Weasel's AutoCreate values, shared with Marten, Fisher and Wolverine.
opts.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;Schema Objects
Polecat manages these SQL Server objects:
Document Tables
pc_doc_{typename}-- One table per document type- Created on first use (first
Store(),Query(), orLoadAsync())
Event Store Tables
pc_events-- Global event logpc_streams-- Stream metadatapc_event_progression-- Async daemon progresspc_event_projection_floors-- Persisted projection start floors (only withEvents.EnableProjectionFloors)
Support Tables
pc_hilo-- HiLo sequence values for numeric IDs
Default Schema
All tables are created in the dbo schema by default. Change this with:
opts.DatabaseSchemaName = "myschema";Weasel Integration
Polecat delegates all DDL generation and execution to Weasel.SqlServer. This provides:
- Diff-based migrations (compares desired vs actual schema)
- Column additions, and under
CreateOrUpdatethe removal of columns the configuration no longer declares; a whole table is never dropped except underAutoCreate.All - Index management
- Foreign key management
- The
db-apply,db-assert,db-patch,db-dumpanddb-listcommand line tools - Registration of the Polecat database as a JasperFx stateful resource, so
resources setupandAddResourceSetupOnStartup()cover it
PolecatActivator
On application startup, Polecat runs the PolecatActivator which:
- Ensures all configured schema objects exist
- Runs schema migrations if
AutoCreateis enabled - Executes initial data seeding if configured
- Starts the async daemon if async projections are registered

JasperFx provides formal support for Polecat and other Critter Stack libraries. Please check our