new-migration

Generates DbUp SQL migration and stored procedure files for ERP database schemas.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill new-migration-aurelian1974
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: new-migration
Source: https://github.com/Aurelian1974/ERPEnterprise/tree/main/.github/skills/new-migration
Command: npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill new-migration-aurelian1974

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing database migrations and stored procedures by hand often leads to inconsistent naming, missing tenant isolation columns, and non-idempotent scripts that break deployments. This Skill enforces a strict, repeatable convention for generating DbUp-compatible SQL files for a modular ERP system. ## Core Features & Use Cases - DDL Migration Generation: Creates versioned migration files (CREATE TABLE, ALTER TABLE, CREATE INDEX, CREATE SCHEMA) with the YYYYMMDD_NNN_Description naming convention, run once by DbUp. - Idempotent Stored Procedures: Generates CREATE OR ALTER stored procedures in a separate folder that DbUp re-runs on every deploy. - Convention Enforcement: Applies snake_case object naming, mandatory tenant_id on every table, tenant-first composite indexes, and a hybrid PK strategy (UUIDv7 for aggregate roots, BIGINT IDENTITY for child/audit tables). - Use Case: When adding a new Invoices module to the ERP, ask for the table, indexes, and creation stored procedure, and receive ready-to-commit SQL files placed in the correct Migrations and StoredProcedures directories. ## Quick Start Ask the assistant to create a new migration for an invoices table with its indexes and a usp_CreateInvoice stored procedure following the project conventions.

Frequently Asked Questions about new-migration

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

FAQPage Schema
How do I create a DbUp migration file for a new table?▼

Create a SQL file named YYYYMMDD_NNN_Description.sql in the module's Migrations folder, where NNN is a three-digit daily sequence starting at 001. DbUp runs each migration exactly once and journals it, so DDL like CREATE TABLE belongs here.

What naming convention should SQL Server tables and indexes follow?▼

Schemas use lowercase, tables and columns use snake_case, and constraints follow explicit patterns: PK_{Table}, FK_{Table}_{ReferencedTable}, UQ_{Table}_{Columns}, and IX_{Table}_{Columns}. Stored procedures use usp_{Action}{Entity}.

Should stored procedures go in the same folder as migrations in DbUp?▼

No. Migrations are one-time journaled scripts, while stored procedures use CREATE OR ALTER and live in a separate StoredProcedures folder configured to run on every deploy, keeping them idempotent and always current.

When should I use UNIQUEIDENTIFIER versus BIGINT IDENTITY for primary keys?▼

Use UNIQUEIDENTIFIER with a C#-generated UUIDv7 for aggregate roots exposed outside the database, and BIGINT IDENTITY(1,1) for child, line-item, and append-only audit tables where insert speed and join performance matter.

Why is NEWID() as a default on primary keys discouraged?▼

NEWID() generates random GUIDs that fragment clustered indexes and hurt insert performance. The convention generates UUIDv7 identifiers in C# before INSERT, giving time-ordered values without database-side defaults.

How do I enforce multi-tenant isolation in SQL table design?▼

Add a tenant_id UNIQUEIDENTIFIER NOT NULL column to every table and make it the first column in every composite index. This keeps queries tenant-scoped and ensures index seeks filter by tenant before any other predicate.