crm-summit/app/Database/Migrations/2026-04-27-000001_CreateFigmaTables.php
mahdahar 6776d539ae feat(figma): add version author id and robust incremental sync pagination
Improve Figma synchronization to persist version author identity and handle API pagination links reliably during incremental sync jobs.

Changes included:
- Added  support end-to-end:
  - New migration  adds column and index.
  -  now allows .
  -  maps user id from Figma version payload ( / ).
  -  snapshot query now selects .
  -  displays Figma User ID column and updates table colspan states.
- Hardened Figma pagination flow in :
  - Follow absolute  URLs when returned by API.
  - Track seen pagination URLs to prevent loops.
  - Support additional page-size query key and URL-safe encoding.
  - Updated request builder to work with absolute endpoints and existing query strings.
- Consolidated schema intent:
  - Moved Volume in drive C: has no label
Volume Serial Number is 2B45-1F84/ columns into initial Figma table migration.
  - Removed superseded follow-up migrations that previously added/dropped these fields.
- Updated project docs and dependencies:
  - Replaced starter README with CRM Summit specific project README.
  - Refreshed  (framework and dependency version bumps).
- Added database artifact: .

Impact:
- Incremental sync should now process paginated version/history feeds more reliably.
- Snapshot API and dashboard expose author-level metadata for auditing and filtering.
- Fresh installs get cleaner Figma schema history from baseline migration.
2026-04-28 05:39:02 +07:00

195 lines
3.9 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,
],
'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('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);
}
}