auth-svc Cursor Rules — Free Cursor Rules Template
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityExtensionsTrending
    CursorRulesauth-svc Cursor Rules
    Back to Rules
    Database

    auth-svc Cursor Rules

    janovix April 15, 2026
    0 copies 0 downloads

    This service has a hybrid column naming convention due to Better Auth's requirements:

    Rule Content
    # Auth-SVC Cursor Rules
    
    ## Database Column Naming Convention - IMPORTANT EXCEPTION
    
    This service has a **hybrid column naming convention** due to Better Auth's requirements:
    
    ### Better Auth Managed Tables (camelCase columns)
    Better Auth generates its own SQL queries that **bypass Prisma's `@map` directives**. 
    These tables MUST use camelCase column names in the database:
    
    | Table | Example Columns |
    |-------|----------------|
    | `users` | `emailVerified`, `banReason`, `banExpires`, `createdAt`, `updatedAt` |
    | `sessions` | `expiresAt`, `ipAddress`, `userAgent`, `activeOrganizationId`, `impersonatedBy`, `userId` |
    | `accounts` | `accountId`, `providerId`, `userId`, `accessToken`, `refreshToken`, `idToken`, `accessTokenExpiresAt` |
    | `verifications` | `expiresAt`, `createdAt`, `updatedAt` |
    | `jwks` | `publicKey`, `privateKey`, `createdAt`, `expiresAt` |
    | `organizations` | `createdAt`, `updatedAt`, `status`, `archivedAt`, `archivedReason` (archive fields applied in `0002_org_archive_user_overage.sql`) |
    | `members` | `organizationId`, `userId`, `createdAt`, `updatedAt` |
    | `invitations` | `organizationId`, `inviterId`, `expiresAt`, `createdAt`, `updatedAt` |
    
    **DO NOT add `@map` directives to these models in `schema.prisma`** - they will be ignored by Better Auth.
    
    ### Custom Auth-SVC Tables (snake_case columns)
    Tables that are NOT managed by Better Auth use standard snake_case via `@map` directives:
    
    | Table | Example Columns |
    |-------|----------------|
    | `organization_settings` | `organization_id`, `date_format`, `avatar_url`, `created_at` |
    | `user_settings` | `user_id`, `date_format`, `avatar_url`, `payment_methods` |
    | `audit_logs` | `event_type`, `entity_type`, `actor_user_id`, `created_at` |
    | `subscription_plans` | `billing_interval`, `stripe_price_id`, `base_price`, `notices_included` |
    | `organization_subscriptions` | `organization_id`, `stripe_customer_id`, `plan_id`, `current_period_start` |
    | `enterprise_licenses` | `organization_id`, `license_key`, `notices_per_month`, `issued_at` |
    | `usage_records` | `organization_id`, `subscription_id`, `period_start`, `notices_created` |
    
    **Always use `@map("snake_case")` directives in Prisma for these models.**
    
    ## Why This Exception Exists
    
    Better Auth's Prisma adapter generates raw SQL queries using the Prisma model field names directly, 
    completely bypassing Prisma's column mapping layer. This is a known limitation of Better Auth.
    
    Options considered:
    1. ✅ **Accept camelCase for Better Auth tables** (chosen) - Works with the library, not against it
    2. ❌ **Force snake_case everywhere** - Would require forking/patching Better Auth
    
    ## Migration File Convention
    
    - `migrations/0001_initial.sql` — baseline full schema for D1 (regenerate from `prisma/schema.prisma` via `pnpm exec prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script`, then merge with the existing `DROP TABLE IF EXISTS` preamble and ordering). New environments apply 0001 then later files in order.
    - `migrations/0002_*.sql` and onward — additive changes only (`ALTER TABLE`, new tables, indexes). Do not fold already-deployed deltas back into 0001 once shipped, or remote DBs that already ran the old 0001 will drift.
    
    Prisma `schema.prisma` reflects the **post-migration** shape; SQL history stays in numbered migration files.
    
    ## Testing After Schema Changes
    
    Always run after any schema changes:
    ```bash
    pnpm run seedLocalDb     # Apply migrations to local D1
    pnpm prisma generate     # Regenerate Prisma client
    pnpm typecheck           # Verify types
    pnpm lint                # Check linting
    pnpm test                # Run tests (may skip on Windows)
    ```
    

    Tags

    prisma

    Comments

    More Rules

    View all

    Kechwafflesnew Cursor Rules

    C
    CODEFORYOU69

    AI DRAMA FACTORY Cursor Rules

    R
    Robert0157

    Site Cursor Rules

    R
    RaphaelVitoi

    KindnessBot Cursor Rules

    F
    foodyogi

    Neptunik Cursor Rules

    F
    fjpedrosa

    Cvcraft Cursor Rules

    C
    CedricCT

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Cursor resource

    • Multi-Service Task Automation with AI-Powered Agent System via WhatsAppn8n · $24.99 · Related topic
    • AI Voice Chatbot with ElevenLabs & OpenAI for Customer Service and Restaurantsn8n · $14.99 · Related topic
    • Extract Google My Business Leads by Service or Location with Bright Datan8n · $14.99 · Related topic
    • Multi-service Terminal: Access Gmail, IRC, Telegram & News with Gemini AIn8n · $9.99 · Related topic
    Browse all workflows