DB CRUD Generator (Custom Tables)
This generator creates a complete CRUD stack for a custom WordPress database table using $wpdb: an installer (dbDelta + versioned upgrades), a repository (create/read/update/delete/list), and an optional REST API controller. Click Generate to get copy-paste ready code.
- Fill the form
- Click Generate (auto-copy)
- Paste into my-plugin.php, zip, upload
- Best for data that should not live in wp_posts/wp_postmeta (logs, queues, tickets, picking, sync tables, etc.).
- Includes safe defaults: column allow-list, prepared queries, and upgrade checks.
- Always back up your database before deploying schema changes.
Used to build class names and the REST route base.
ticket
→ REST: /ticket, PHP classes: Ticket_Repository
The table name suffix. WordPress prefix is added automatically via $wpdb->prefix.
my_plugin_tickets
→ Real table: wp_my_plugin_tickets (or wp_2_... on multisite)
The REST API namespace used under /wp-json/{namespace}/...
my-plugin/v1
→ Base: /wp-json/my-plugin/v1/ticket
Users must have this capability to create/update/delete via REST. Reads are public by default.
manage_options
→ Admin-only writes
Stored in wp_options to track installed schema version and run upgrades safely.
my_plugin_db_version
→ Used by Installer::maybe_upgrade()
Constant used as the “target version” for schema upgrades (usually your plugin version constant).
MY_PLUGIN_VERSION
→ When version changes, schema upgrades can run
Working with custom database tables in WordPress often requires writing a lot of repetitive code: table creation with dbDelta(), versioning logic, upgrade routines, and basic CRUD operations using $wpdb.
The Database CRUD Generator helps you generate a clean, structured foundation for custom database tables, including dbDelta table creation, versioned upgrades, and CRUD helper methods, so you can focus on your business logic instead of boilerplate.
Why Use Custom Database Tables in WordPress?
While WordPress post types and meta tables work well for many use cases, some scenarios require custom tables for performance, structure, or scalability reasons, such as:
- Large datasets or logs
- Complex relationships
- High-frequency writes
- Reporting and analytics
- Internal tools and integrations
Using custom tables gives you full control over schema design and query performance.
What This Database CRUD Generator Creates
This generator outputs developer-ready boilerplate that typically includes:
- A
dbDelta()SQL schema for table creation - Proper charset and collation handling
- A table version constant
- Activation hook logic
- Upgrade logic when the table schema changes
- A structured
$wpdbhelper class with:create()get()get_all()update()delete()
The generated code follows WordPress best practices and can be pasted directly into your plugin.
dbDelta + Upgrade Logic
One of the most error-prone parts of custom tables is handling schema changes over time.
This generator includes:
- A versioned table schema
- Automatic upgrade logic triggered on plugin update
- Safe use of
dbDelta()to apply changes without dropping data
This makes it easier to maintain database changes across plugin versions.
How to Use the Database CRUD Generator
- Define your table name and database prefix usage.
- Add table columns and data types.
- Specify primary keys and indexes.
- Generate the code.
- Copy the generated output into your plugin.
The output is displayed in a readable code editor (CodeMirror) and can be copied instantly.
Best Practices When Using Custom Tables
- Always use
$wpdb->prepare()for dynamic queries. - Keep table schemas simple and well indexed.
- Version your schema to support upgrades.
- Avoid direct SQL in multiple places — centralize it in a helper class.
- Test table creation and upgrades on staging environments.
Who Is This Tool For?
The Database CRUD Generator is intended for:
- WordPress plugin developers
- Teams building internal tools
- Projects requiring structured or high-volume data storage
- Developers who want consistent and maintainable database code
If you find yourself repeatedly writing dbDelta() logic and CRUD helpers, this tool can save you significant time.
