crud-model

Enforce PowerX CRUD model conventions for multi-tenant GORM entities.

357|65|Updated Jul 29, 2022
One-click install
npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-model
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crud-model
Source: https://github.com/ArtisanCloud/PowerX/tree/main/.codex/skills/crud/model
Command: npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-model

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PowerX CRUD Model standardizes GORM models to support multi-tenant data, consistent naming, and streamlined migrations, reducing drift between modules.

Core Features & Use Cases

  • Embeds PowerModel/PowerUUIDModel and includes TenantID and DeletedAt to enable multi-tenant isolation and soft deletion.
  • Enforces table naming returning schema-qualified names via TableName() and uses the PowerXSchema constant.
  • Standardizes JSON fields with datatypes.JSON (JSONB) and provides status field with default value and indexing.
  • Integrates with module migrations by providing a Migrate<Module>Models function and central migrate entry to run AutoMigrate.

Quick Start

Create a new GORM model that follows the embedded PowerModel/PowerUUIDModel, ensuring TenantID, DeletedAt, and Status fields, and register its migration with the module's AutoMigrate entry.

Frequently Asked Questions about crud-model

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

FAQPage Schema
How do I set up a multi-tenant GORM model with TenantID and soft deletion?

To set up a multi-tenant GORM model, embed PowerModel or PowerUUIDModel and include TenantID and DeletedAt fields to enable data isolation and soft deletion across your modules.

What's the best way to standardize GORM table naming and migrations across modules?

Standardize GORM table naming by implementing TableName() to return schema-qualified names using the PowerXSchema constant, and centralize migrations via AutoMigrate in a module-specific migrate.go file.

How does datatypes.JSON handle JSONB fields in GORM models?

Datatypes.JSON handles JSONB fields by standardizing JSON data storage in GORM models, ensuring consistent serialization and database-level JSONB column mapping for complex field structures.

Can I use AutoMigrate with module-specific migrate.go files for PowerX models?

Yes, you can use AutoMigrate with module-specific migrate.go files by providing a Migrate<Module>Models function that serves as a central entry point to run migrations for PowerX models.

Why do I need schema-qualified names for multi-tenant GORM entities?

Schema-qualified names are needed for multi-tenant GORM entities to ensure consistent table naming across the PowerX persistence layer, reducing schema drift and preventing data isolation failures.

Does the PowerX CRUD model support default values and indexing for status fields?

Yes, the PowerX CRUD model supports status fields by providing default values and database indexing, ensuring query performance and consistent state management across multi-tenant entities.