first commit

This commit is contained in:
root
2026-01-10 16:16:39 +03:00
commit 5f5a28e292
154 changed files with 21454 additions and 0 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateOrganizationSubscriptionsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'organization_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'module_code' => [
'type' => 'VARCHAR',
'constraint' => 50, // 'crm', 'booking', 'proof', 'tasks'
],
'status' => [
'type' => 'ENUM',
'constraint' => ['trial', 'active', 'expired', 'cancelled'],
'default' => 'trial',
],
'expires_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
// Организация не может иметь две активные подписки на один модуль одновременно
$this->forge->addUniqueKey(['organization_id', 'module_code']);
$this->forge->addForeignKey('organization_id', 'organizations', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('organization_subscriptions');
}
public function down()
{
$this->forge->dropTable('organization_subscriptions');
}
}