add EventManager and Subscription

This commit is contained in:
root
2026-01-13 12:08:40 +03:00
parent 3d39c1ba07
commit 3c24c250e5
6 changed files with 785 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddTrialEndsAtToSubscriptions extends Migration
{
public function up()
{
// Добавляем поле trial_ends_at для отслеживания окончания триала
$this->forge->addColumn('organization_subscriptions', [
'trial_ends_at' => [
'type' => 'DATETIME',
'null' => true,
'after' => 'status',
'comment' => 'Дата окончания триального периода',
],
]);
// Обновляем существующие триальные подписки (14 дней от created_at)
$this->db->query("
UPDATE organization_subscriptions
SET trial_ends_at = DATE_ADD(created_at, INTERVAL 14 DAY)
WHERE status = 'trial' AND trial_ends_at IS NULL
");
}
public function down()
{
$this->forge->dropColumn('organization_subscriptions', 'trial_ends_at');
}
}