PHPackages                             wptechnix/wp-tables-schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. wptechnix/wp-tables-schema

ActiveLibrary[Database &amp; ORM](/categories/database)

wptechnix/wp-tables-schema
==========================

A developer-friendly library for creating and managing custom WordPress database tables with schema definition, versioning, and migrations.

1.0.1(7mo ago)3301MITPHPPHP ^8.0CI passing

Since Oct 10Pushed 7mo agoCompare

[ Source](https://github.com/WPTechnix/wp-tables-schema)[ Packagist](https://packagist.org/packages/wptechnix/wp-tables-schema)[ RSS](/packages/wptechnix-wp-tables-schema/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

WP Tables Schema
================

[](#wp-tables-schema)

A fluent, powerful, and developer-friendly library for creating and managing custom database tables in WordPress. Define your table schemas with an expressive API, handle versioning and migrations with ease, and build robust, modern data layers for your plugins.

[![Latest Version](https://camo.githubusercontent.com/7c7cdc885382cc6522ca0bd9eb0fb669419e533406e7c6f53ed5b34ee96a9199/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7770746563686e69782f77702d7461626c65732d736368656d612e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/wptechnix/wp-tables-schema)[![Total Downloads](https://camo.githubusercontent.com/3e7de84c58488e6efe7066b7cc90e02df1b364ec26d28374ad8a2161be99276e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7770746563686e69782f77702d7461626c65732d736368656d612e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/wptechnix/wp-tables-schema)[![License](https://camo.githubusercontent.com/470203b94387d2c1d7eb9fce60121f0f002a83dae1fdbd53af7367ffbca7cd53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7770746563686e69782f77702d7461626c65732d736368656d612e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/wptechnix/wp-tables-schema)

---

Key Features
------------

[](#key-features)

- **Fluent Schema Builder**: Effortlessly define table columns, indexes, and relationships using a clean, chainable API.
- **Automated Migrations**: A simple, version-based migration system lets you evolve your database schema safely and predictably over time.
- **WordPress Integration**: Built to work seamlessly with the `$wpdb` object, prefixes, and the WordPress environment, including full multisite support.
- **Code-First Approach**: Define your entire database schema in version-controllable PHP, making it easy to track changes and collaborate.
- **Rich Type &amp; Index Support**: Supports a wide range of MySQL/MariaDB column types, all index types (`UNIQUE`, `FULLTEXT`, `SPATIAL`), and foreign key constraints.
- **Powerful Helpers**: Includes an abstract `Meta_Table` class to instantly create WordPress-style metadata tables, plus schema macros for common patterns like timestamps and soft deletes.

Requirements
------------

[](#requirements)

- PHP 8.x
- WordPress 5.0+
- MySQL 5.6+ or MariaDB 10.1+

Installation
------------

[](#installation)

The recommended way to install this library is through [Composer](https://getcomposer.org/):

```
composer require wptechnix/wp-tables-schema
```

Quick Start Guide
-----------------

[](#quick-start-guide)

Let's create a custom database table for "Events" in 2 simple steps.

### Step 1: Define Your Table Class

[](#step-1-define-your-table-class)

Create a new PHP class that extends `Table`. This class is the single source of truth for your table's structure and version.

**`src/Database/Tables/Events_Table.php`**

```
