---
title: "Database schema — Coupons for Laravel | Roundly"
description: "The coupons and coupon_redemptions tables column by column — types, defaults, the shared currency column and soft deletes."
url: https://roundly-consulting.com/open-source/docs/coupons-for-laravel/database-schema
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Coupons for Laravel](https://roundly-consulting.com/open-source/docs/coupons-for-laravel.md)

# Database schema

Both tables come from the published migrations. Money columns are money-for-laravel decimal(38,0) minor-unit columns that share one currency column per row.

## coupons

| Column | Type | Notes |
| --- | --- | --- |
| `id` | `bigint PK` | |
| `type` | `string` | Default fixed. |
| `value` | `bigint` | Minor units (Fixed) or basis points (Percentage). |
| `code` | `string, indexed` | Stored trimmed and upper-cased. |
| `usage` | `integer` | Default 0. |
| `max_usage` | `integer` | Default 0 = unlimited. |
| `max_usage_per_redeemer` | `unsigned integer` | Default 0 = unlimited. |
| `currency` | `currencyCode, nullable` | The currency lock. |
| `minimum_spend` | `money, nullable` | Shares currency. |
| `max_discount` | `money, nullable` | Shares currency. |
| `activated_at` | `timestamp, nullable` | Null = not yet active. |
| `expires_at` | `timestamp, nullable` | Null = no expiry. |
| `meta` | `jsonb, nullable` | Cast to a collection. |
| `created_at, updated_at, deleted_at` | `timestamps` | Soft deletes. |
| `undeleted_code` | `string, nullable, stored generated, unique` | Mirrors code while the row isn’t trashed and is null once it is, so codes stay unique among live coupons. Hidden from arrays and JSON. |

## coupon\_redemptions

| Column | Type | Notes |
| --- | --- | --- |
| `id` | `bigint PK` | |
| `coupon_id` | `foreignId → coupons.id` | Cascade on delete. |
| `redeemer_type, redeemer_id` | `morphKey, nullable` | Key type from coupons.key\_type; null for guest redemptions. |
| `amount_discounted, currency` | `money` | The recorded discount. |
| `created_at, updated_at, deleted_at` | `timestamps` | Soft deletes. |

code is indexed, not unique: uniqueness among live coupons comes from the unique index on the generated undeleted\_code column, so a soft-deleted coupon’s code can be issued again. That needs MySQL/MariaDB, PostgreSQL or SQLite — SQL Server’s unique indexes treat NULLs as equal. The model leaves undeleted\_code out of replicate().

On SQLite, money’s cast refuses amounts beyond int64 (InvalidMoneyValue).

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/coupons-for-laravel.md)
