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'); } }