crm-summit/app/Database/Migrations/2026-04-27-000001_CreateFigmaTables.php
mahdahar 9138e0286a feat(figma): add DB-backed dashboard filters and paginated APIs
- add Figma API endpoints for summary, users, snapshots, comments, and admin sync
- support date and user filters plus pagination for snapshots and comments
- expand sync service and schema to store Figma user ids
- refresh dashboard UI with summary cards, filters, pagination, and sync action
- fold figma_user_id into base migration and remove extra migration
2026-04-28 09:01:32 +07:00

207 lines
4.2 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateFigmaTables extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
'auto_increment' => true,
],
'file_key' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'version' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'label' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'description' => [
'type' => 'LONGTEXT',
'null' => true,
],
'last_modified' => [
'type' => 'DATETIME',
'null' => true,
],
'editor_type' => [
'type' => 'VARCHAR',
'constraint' => 100,
'null' => true,
],
'last_synced_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey('file_key');
$this->forge->createTable('figma_files', true);
$this->forge->addField([
'id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
'auto_increment' => true,
],
'file_id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
],
'figma_version_id' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'version' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'label' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'description' => [
'type' => 'LONGTEXT',
'null' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'editor_type' => [
'type' => 'VARCHAR',
'constraint' => 100,
'null' => true,
],
'figma_user_id' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'user_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'last_modified_figma' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at_figma' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey(['file_id', 'figma_version_id']);
$this->forge->addKey('file_id');
$this->forge->addKey('figma_user_id');
$this->forge->addKey('user_name');
$this->forge->addKey('created_at_figma');
$this->forge->addKey('last_modified_figma');
$this->forge->createTable('figma_file_versions', true);
$this->forge->addField([
'id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
'auto_increment' => true,
],
'file_id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
],
'figma_comment_id' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'user_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'message' => [
'type' => 'LONGTEXT',
'null' => true,
],
'is_resolved' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'resolved_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at_figma' => [
'type' => 'DATETIME',
'null' => true,
],
'client_meta_json' => [
'type' => 'LONGTEXT',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey('figma_comment_id');
$this->forge->addKey('file_id');
$this->forge->addKey('created_at_figma');
$this->forge->createTable('figma_comments', true);
}
public function down()
{
$this->forge->dropTable('figma_comments', true);
$this->forge->dropTable('figma_file_versions', true);
$this->forge->dropTable('figma_files', true);
}
}