A female engineer works on code in a contemporary office setting, showcasing software development.

Database CRUD Generator (WordPress)

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.

3-step Quick start
  1. Fill the form
  2. Click Generate (auto-copy)
  3. 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.
What is this?
Used to build class names and the REST route base.
Example: ticket → REST: /ticket, PHP classes: Ticket_Repository
What is this?
The table name suffix. WordPress prefix is added automatically via $wpdb->prefix.
Example: my_plugin_tickets → Real table: wp_my_plugin_tickets (or wp_2_... on multisite)
What is this?
The REST API namespace used under /wp-json/{namespace}/...
Example: my-plugin/v1 → Base: /wp-json/my-plugin/v1/ticket
What is this?
Users must have this capability to create/update/delete via REST. Reads are public by default.
Example: manage_options → Admin-only writes
What is this?
Stored in wp_options to track installed schema version and run upgrades safely.
Example: my_plugin_db_version → Used by Installer::maybe_upgrade()
What is this?
Constant used as the “target version” for schema upgrades (usually your plugin version constant).
Example: MY_PLUGIN_VERSION → When version changes, schema upgrades can run
Columns Add your table columns below. The generator will ensure an id primary key exists.
Name
SQL Type
Null
Default
Extra
Tip: After generating, paste the code into my-plugin.php, zip it, and upload it as a plugin. Always test on staging first.

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 $wpdb helper 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

  1. Define your table name and database prefix usage.
  2. Add table columns and data types.
  3. Specify primary keys and indexes.
  4. Generate the code.
  5. 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.