add EventManager and Subscription
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user