Files
MoneyFlix/crm/Core/Database/Migrations/CreateDetectionRulesTable.php
1sonhador 9d43854277 feat: Initial MoneyFlix project setup
- Created separate MoneyFlix project directory
- Copied Node.js redirector from production server
- Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views)
- Created comprehensive documentation (README_MONEYFLIX.md)
- Added sync script to keep CRM code updated (sync-from-crm.sh)
- Configured .gitignore for Node.js and PHP
- Set up proper project structure for multi-client isolation

This separates MoneyFlix from the main CRM to avoid confusion
between different client systems and provides a dedicated
environment for MoneyFlix-specific development and maintenance.
2025-10-03 12:09:41 +01:00

46 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Core\Database\Migrations;
use App\Core\Database\Migration;
use App\Core\Database\SchemaBuilder;
/**
* Migration: Create Detection Rules Table
*
* Creates advertising_detection_rules table for configurable brand detection rules.
* This allows brands to define custom detection patterns for URLs, domains, paths, etc.
*/
class CreateDetectionRulesTable extends Migration
{
public function up(): void
{
$this->createTable('advertising_detection_rules', function (SchemaBuilder $table) {
$table->id();
$table->unsignedBigInteger('brand_id')->index()->comment('Foreign key to advertising_brands');
$table->varchar('name', 255)->notNull()->comment('Rule name for identification');
$table->text('description')->nullable()->comment('Rule description');
$table->varchar('rule_type', 50)->notNull()->comment('regex, domain, path, parameter, custom');
$table->text('rule_pattern')->notNull()->comment('regex pattern, domain, path pattern, etc.');
$table->json('rule_conditions')->nullable()->comment('additional conditions');
$table->integer('priority')->default(0)->index()->comment('higher priority = checked first');
$table->boolean('is_active')->default(true)->index()->comment('rule status');
$table->json('extraction_rules')->nullable()->comment('how to extract data from matches');
$table->json('fallback_data')->nullable()->comment('fallback data if no match');
$table->timestamps();
// Foreign key constraints
$table->foreignKey('brand_id', 'advertising_brands', 'id', 'CASCADE', 'CASCADE');
// Indexes for performance
$table->index(['brand_id', 'is_active', 'priority'], 'idx_brand_active_priority');
});
}
public function down(): void
{
$this->schema->dropTable('advertising_detection_rules');
}
}