sql-migration-scripts

Writes idempotent SQL migration scripts for SharpPS Sitecore database projects.

Updated Jul 24, 2026
One-click install
npx skills add https://github.com/gweone/agent-plugins --skill sql-migration-scripts-gweone
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-migration-scripts
Source: https://github.com/gweone/agent-plugins/tree/main/plugin/sharpps-sitecore/skills/sql-migration-scripts
Command: npx skills add https://github.com/gweone/agent-plugins --skill sql-migration-scripts-gweone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SharpPS Sitecore solutions replay every *.sql file in a configured Scripts folder on every run of the Database.Tools console project, so any non-idempotent statement fails or corrupts state on the second execution. This Skill explains how to locate the correct Database project and Scripts folder by structure, choose between a one-time EF Core migration and the replay-every-run scripts folder, and write each statement type with the idempotency guard it requires. ## Core Features & Use Cases - Project and folder discovery: Locate the Database project via its DbContext/Migration classes and confirm the Scripts folder through the MigrationScriptPath config key in the sibling Database.Tools project, instead of guessing fixed project names. - Mechanism selection: Decide between an apply-once EF Core migration under Migrations/ and a *.sql file that is re-asserted on every deploy, or a Manual/ folder for one-off DBA scripts. - Idempotency patterns: Provides ready-to-copy guards for CREATE TABLE (OBJECT_ID check), column add/drop (COL_LENGTH check), seed data (IF NOT EXISTS on a stable key), and CREATE OR ALTER for stored procedures and functions. - Use Case: You need to add a CreatedBy column and a new stored procedure to a Sitecore solution's database. The Skill guides you to the correct Scripts folder and gives you a script that runs cleanly no matter how many times Database.Tools executes. ## Quick Start Ask the assistant to write an idempotent SQL script that adds a column and a stored procedure to the SharpPS Sitecore database project's Scripts folder.

Frequently Asked Questions about sql-migration-scripts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a SQL script to a SharpPS Sitecore database project?

Find the Database project by searching for a class deriving from DbContext or Migration, then locate its folder of .sql files confirmed by the MigrationScriptPath config key in the sibling Database.Tools project. Place your idempotent .sql file there and it runs on every execution.

When should I use an EF Core migration versus a .sql scripts folder?

Use an EF Core migration under Migrations/ for one-time structural changes driven by the C# entity model, tracked in __EFMigrationsHistory. Use the .sql Scripts folder for table patches, stored procedures, functions, and seed data you want re-asserted on every deploy.

How do I make a SQL migration script idempotent in SQL Server?

Guard CREATE TABLE with an OBJECT_ID existence check, column add/drop with COL_LENGTH checks, and seed inserts with IF NOT EXISTS on a stable key. Use CREATE OR ALTER for stored procedures and functions, which is idempotent without any guard.

Why does my SQL script fail the second time Database.Tools runs?

The Database.Tools runner deletes the ScriptsMigration history row so every .sql file replays on each run. Any statement without an existence guard, such as an unguarded CREATE TABLE or INSERT, errors or duplicates data on the second execution.

Can I include a USE database statement in migration scripts?

No. The runner comments out USE statements because the connection string already targets the correct database. Including one is dead weight at best and misleading at worst, so omit it and separate batches with GO instead.