MS SQL Server Driver
The MSSQL driver supports Queen's core flow using SQL Server application locks.
Packages
import (
"database/sql"
"github.com/yaop-labs/queen"
"github.com/yaop-labs/queen/drivers/mssql"
_ "github.com/microsoft/go-mssqldb"
)
db, err := sql.Open("sqlserver", os.Getenv("MSSQL_DSN"))
if err != nil {
return err
}
q := queen.New(mssql.New(db))
How it works
| Area | Implementation |
|---|---|
| Migration table | Created with IF OBJECT_ID(..., 'U') IS NULL. |
| Identifier quoting | Brackets. |
| Placeholders | @p1, @p2, ... |
| Locking | sp_getapplock with LockOwner = 'Session' on a pinned *sql.Conn. |
| Unlock | sp_releaseapplock on the same connection. |
| Lock name | queen_lock_ plus migration table name. |
| Execution | database/sql transaction through the shared base driver. |
| Atomic record | No. Migration body commits before Record. |
Guarantees
- Lock connection lifecycle is mutex-guarded.
- Nested lock attempts on the same driver fail deterministically.
- Table names used in
OBJECT_ID(N'...')string literals escape single quotes.
Limitations
- Migration metadata is not atomic with the migration body.
- SQL Server DDL transaction behavior depends on the statement and database settings.
- This path is supported but less heavily exercised than PostgreSQL.
DSN
sqlserver://user:pass@localhost:1433?database=myapp