---
title: Database Schema
description: "# Database Schema Smart Cycle Discounts uses custom tables with the `wsscd_` prefix. ## Source of Truth Schema evolves through migrations. Use these files as the authoritative reference: - `includes/database/class-database-manager.php` - `includes/database/migrations/001-initial-schema.php` - `includes/database/migrations/*.php` ## Core Tables The plugin registers…"
url: "https://webstepper.io/docs/smart-cycle-discounts/developer-documentation/database-schema/"
updated: "2026-07-28"
category: Developer Documentation
---

# Database Schema

# Database Schema

Smart Cycle Discounts uses custom tables with the `wsscd_` prefix.

## Source of Truth

Schema evolves through migrations. Use these files as the authoritative reference:

- `includes/database/class-database-manager.php`
 - `includes/database/migrations/001-initial-schema.php`
 - `includes/database/migrations/*.php`

## Core Tables

The plugin registers these tables via `WSSCD_Database_Manager`:

- `{prefix}wsscd_campaigns`
 - `{prefix}wsscd_campaign_conditions`
 - `{prefix}wsscd_active_discounts`
 - `{prefix}wsscd_analytics`
 - `{prefix}wsscd_customer_usage`
 - `{prefix}wsscd_campaign_recurring`
 - `{prefix}wsscd_activity_log`
 - `{prefix}wsscd_product_analytics`
 - `{prefix}wsscd_migrations`

> **Changed in 2.2.0:** the `{prefix}wsscd_recurring_cache` table (the old occurrence cache) was removed, and `{prefix}wsscd_campaign_recurring` was simplified to the new rule shape (`active_days_mode`, `weekdays`, `month_days`, `window_mode`, `window_start`, `window_end`). The legacy columns (`recurrence_pattern`, `recurrence_interval`, `recurrence_mode`, `recurrence_count`, `recurrence_end_type`, `recurrence_end_date`, `next_occurrence_date`) were dropped.

## Notes

- `{prefix}` already includes the trailing underscore from `$wpdb->prefix` (for example `wp_`).
 - Table columns can change by plugin version because migrations are additive.
 - For production-safe checks, query `INFORMATION_SCHEMA` or use repository classes rather than hardcoding old column sets.

## Example: Resolving a Full Table Name

```php
 global $wpdb;
 $table = $wpdb->prefix . 'wsscd_campaigns';
 ```

## Maintenance Examples

```sql
 OPTIMIZE TABLE {prefix}wsscd_campaigns;
 OPTIMIZE TABLE {prefix}wsscd_analytics;
 OPTIMIZE TABLE {prefix}wsscd_activity_log;
 ```

```sql
 DELETE FROM {prefix}wsscd_analytics
 WHERE created_at
