Many fixes

This commit is contained in:
root
2026-01-16 21:58:12 +03:00
parent b810a17649
commit 77f76c8c28
45 changed files with 3392 additions and 1243 deletions
@@ -5,12 +5,19 @@ namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Migration для создания таблицы подписок организаций на тарифы
* Использует ту же структуру что и organization_subscriptions для модулей
* Миграция для удаления таблицы подписок на тарифы
*
* Плановая система тарифов заменена на модульную систему подписок.
* Таблица organization_plan_subscriptions больше не используется.
*/
class CreateOrganizationPlanSubscriptionsTable extends Migration
class DropOrganizationPlanSubscriptionsTable extends Migration
{
public function up()
{
$this->forge->dropTable('organization_plan_subscriptions', true);
}
public function down()
{
$this->forge->addField([
'id' => [
@@ -53,18 +60,10 @@ class CreateOrganizationPlanSubscriptionsTable extends Migration
]);
$this->forge->addKey('id', true);
// Организация не может иметь две активные подписки на один тариф одновременно
$this->forge->addUniqueKey(['organization_id', 'plan_id']);
$this->forge->addForeignKey('organization_id', 'organizations', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('plan_id', 'plans', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('organization_plan_subscriptions');
}
public function down()
{
$this->forge->dropTable('organization_plan_subscriptions');
}
}
@@ -0,0 +1,75 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Миграция для создания таблицы настроек модулей
*
* Хранит переопределённые настройки модулей (цены, описание, триал).
*/
class CreateModuleSettingsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'module_code' => [
'type' => 'VARCHAR',
'constraint' => 50,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'description' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'price_monthly' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'price_yearly' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'trial_days' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'is_active' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 1,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey('module_code');
$this->forge->createTable('module_settings');
}
public function down()
{
$this->forge->dropTable('module_settings', true);
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddUpdatedAtToSubscriptions extends Migration
{
public function up()
{
$this->forge->addColumn('organization_subscriptions', [
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
}
public function down()
{
$this->forge->dropColumn('organization_subscriptions', 'updated_at');
}
}