MSSQL Storage
Enterprise-grade storage adapter for Microsoft SQL Server
MSSQL Storage
The @stepflowjs/storage-mssql adapter provides an enterprise-grade storage backend using Microsoft SQL Server. It uses sp_getapplock for distributed locking and MERGE statements for atomic updates.
Installation
pnpm add @stepflowjs/storage-mssqlUsage
import { Stepflow } from "@stepflowjs/core";
import { MssqlStorageAdapter } from "@stepflowjs/storage-mssql";
const stepflow = new Stepflow({
storage: new MssqlStorageAdapter({
server: "localhost",
database: "StepflowDB",
user: "sa",
password: "YourStrongPassword",
options: {
encrypt: true,
trustServerCertificate: true,
},
}),
});Configuration Options
| Option | Type | Description |
|---|---|---|
server | string | SQL Server host |
database | string | Database name |
user | string | Database user |
password | string | Database password |
port | number | Database port (default: 1433) |
schema | string | Database schema (default: stepflow) |
poolSize | number | Maximum number of connections in the pool (default: 20) |
options.encrypt | boolean | Use encryption (default: true) |
options.trustServerCertificate | boolean | Trust self-signed certificates (default: false) |
Features
- Enterprise Ready: Full support for Microsoft SQL Server features.
- Distributed Locking: Uses
sp_getapplockfor reliable leader election. - Atomic Updates: Uses
MERGEstatements to handle upserts and state transitions atomically. - Automatic Migrations: Automatically creates schemas, tables, and indexes on startup.
Environment Variables
MSSQL_SERVER=localhost
MSSQL_DATABASE=StepflowDB
MSSQL_USER=sa
MSSQL_PASSWORD=YourStrongPassword