skills/vendix-prisma-migrations/SKILL.md
Production-safe Prisma migration patterns for Vendix: idempotent SQL, enum handling, data-impact headers, destructive-operation bans, failed migration recovery, and Prisma 7 config. Trigger: When creating migrations, editing migration SQL, deploying migrations, or recovering from failed Prisma migrations.
npx skillsauth add rzyfront/vendix vendix-prisma-migrationsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
apps/backend/prisma/migrations/**/migration.sql.P3009, P3006, P3008, P3012, enum conflicts, or checksum mismatches.The current backend Dockerfile runs node dist/src/main.js; it does not currently run npx prisma migrate deploy in the container CMD. Do not claim startup migrations unless deployment pipeline code confirms it.
Production deploys still must run prisma migrate deploy somewhere in the release process. Migration failures can still block deploys and must be resolved at database/migration level.
npm run db:migrate:dev -w apps/backend
npm run db:migrate:prod -w apps/backend
npm run prisma:generate -w apps/backend
For SQL-first review:
npx prisma migrate dev --create-only --name describe_change
ALTER TYPE ... ADD VALUE; use IF NOT EXISTS or guarded DO $$.TRUNCATE ... CASCADE.DELETE FROM table or UPDATE table SET ... without WHERE.ON DELETE CASCADE to business parent tables without explicit approval.DATA IMPACT header, FK/cascade analysis, and representative dry-run.Use this pattern for any migration that modifies rows or has non-trivial production risk:
-- DATA IMPACT:
-- Tables affected: subscription_invoices
-- Expected row changes: remap state partially_paid -> issued if present
-- Destructive operations: none
-- FK/cascade risk: none
-- Idempotency: guarded by WHERE and IF EXISTS checks
-- Approval: documented in chat/PR
ALTER TYPE "my_enum" ADD VALUE IF NOT EXISTS 'new_value';
ALTER TABLE "my_table" ADD COLUMN IF NOT EXISTS "new_col" TEXT;
CREATE INDEX IF NOT EXISTS "idx_my_table_new_col" ON "my_table"("new_col");
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'my_enum') THEN
CREATE TYPE "my_enum" AS ENUM ('a', 'b');
END IF;
END $$;
Recent migrations also use guarded pg_attribute, pg_constraint, pg_enum, ON CONFLICT DO NOTHING, and pre-flight validation before enum conversion. Follow those existing patterns.
Postgres enum additions can be problematic when the same migration later uses the new value. If needed, split into two migrations:
General workflow:
_prisma_migrations for finished_at IS NULL.Use prisma migrate resolve --applied <migration> or --rolled-back <migration> when appropriate and safe.
If clearing a table with inbound FKs is explicitly approved:
pg_constraint.CASCADE.ON DELETE behavior.vendix-prisma-schemavendix-prisma-scopesvendix-prisma-seedgit-workflowdevelopment
Mobile app development rules for Vendix Expo/React Native project. Trigger: When editing, creating, or modifying any file under apps/mobile, or when developing mobile-specific features.
development
Feature gating by store subscription state: global store write guard, AI feature gate, Redis feature resolution, quota consumption, frontend paywall interceptor, banner, and subscription UI states. Trigger: When adding feature gates, paywalls, subscription-based access control, protecting store write operations, AI feature gates, or rollout flags.
testing
SaaS subscription billing for Vendix stores: plan pricing, invoices, Wompi platform payments, manual payments, partner commissions, payouts, proration, and dunning. Trigger: When creating SaaS invoices, working with partner rev-share, margin/surcharge pricing, invoice sequence allocation, partner payout batches, subscription payments, manual payments, or dunning flows.
development
Periodic quota counters with Redis, UTC period keys, Lua-based idempotent AI quota consumption, request-id deduplication, and post-success consumption. Trigger: When building quota counters, enforcing monthly/daily feature caps, or reusing AI quota patterns for uploads, emails, exports, or rate-limited features.