# fluent-cart/1.6.5/database/Migrations/AppliedCouponsMigrator.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.5. 36 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.5/code/database/Migrations/AppliedCouponsMigrator.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.5/raw/database/Migrations/AppliedCouponsMigrator.php
- Modified: 2026-08-11T13:30:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.5/code/database/Migrations/AppliedCouponsMigrator.php#L10-L20`.

```php
<?php

namespace FluentCart\Database\Migrations;


use FluentCart\Framework\Database\Schema;

class AppliedCouponsMigrator extends Migrator
{

	public static string $tableName = 'fct_applied_coupons';

	public static function getSqlSchema(): string
	{
        $indexPrefix = 'fct_acoup_';
		return "`id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
            `order_id` BIGINT UNSIGNED NOT NULL,
            `coupon_id` BIGINT UNSIGNED NULL,
			`code` VARCHAR(100) NOT NULL ,
			`amount` double NOT NULL,
			`created_at` DATETIME NULL ,
			`updated_at` DATETIME NULL,
        	INDEX `{$indexPrefix}_code_idx` (`code`),
        	INDEX `{$indexPrefix}_coupon_order_idx` (`coupon_id`, `order_id`)";
	}

	public static function migrated()
	{
		// Per-customer usage counting filters by coupon_id and joins orders
		// through order_id (CanValidateCoupon::hasMaxPerUserLimit,
		// DiscountService::isCouponValid) — without this, every validation
		// scans the table as usage history grows.
		static::addIndexIfNotExists('fct_acoup__coupon_order_idx', ['coupon_id', 'order_id']);
	}
}

```
