71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
||
|
||
namespace App\Database\Migrations;
|
||
|
||
use CodeIgniter\Database\Migration;
|
||
|
||
class CreateOrganizationsTable extends Migration
|
||
{
|
||
public function up()
|
||
{
|
||
$this->forge->addField([
|
||
'id' => [
|
||
'type' => 'INT',
|
||
'constraint' => 11,
|
||
'unsigned' => true,
|
||
'auto_increment' => true,
|
||
],
|
||
'owner_id' => [
|
||
'type' => 'INT',
|
||
'constraint' => 11,
|
||
'unsigned' => true,
|
||
],
|
||
'name' => [
|
||
'type' => 'VARCHAR',
|
||
'constraint' => 255,
|
||
],
|
||
'type' => [
|
||
'type' => 'ENUM',
|
||
'constraint' => ['business', 'personal'],
|
||
'default' => 'business',
|
||
],
|
||
'logo' => [
|
||
'type' => 'VARCHAR',
|
||
'constraint' => 255,
|
||
'null' => true,
|
||
],
|
||
'requisites' => [
|
||
'type' => 'JSON',
|
||
'null' => true, // Для хранения ИНН, ОГРН, адреса
|
||
],
|
||
'trial_ends_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true, // Дата окончания триала (14 дней по ТЗ)
|
||
],
|
||
'settings' => [
|
||
'type' => 'JSON',
|
||
'null' => true,
|
||
],
|
||
'created_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true,
|
||
],
|
||
'updated_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true,
|
||
],
|
||
'deleted_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true, // Для мягкого удаления
|
||
],
|
||
]);
|
||
$this->forge->addKey('id', true);
|
||
$this->forge->addForeignKey('owner_id', 'users', 'id', 'CASCADE', 'CASCADE');
|
||
$this->forge->createTable('organizations');
|
||
}
|
||
|
||
public function down()
|
||
{
|
||
$this->forge->dropTable('organizations');
|
||
}
|
||
} |