# fluent-boards/1.41/database/Migrations/AttachmentMigrator.php

FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration, version 1.41. 48 lines.

- Page: https://pluginprobe.com/plugins/fluent-boards/1.41/code/database/Migrations/AttachmentMigrator.php
- Raw: https://pluginprobe.com/plugins/fluent-boards/1.41/raw/database/Migrations/AttachmentMigrator.php
- Modified: 2024-05-31T06:41:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-boards/1.41/code/database/Migrations/AttachmentMigrator.php#L10-L20`.

```php
<?php

namespace FluentBoards\Database\Migrations;

class AttachmentMigrator
{
    /**
     * Attachments Table.
     * @param bool $isForced
     * @return void
     */
    public static function migrate($isForced = true)
    {
        global $wpdb;

        $charsetCollate = $wpdb->get_charset_collate();

        $table = $wpdb->prefix . 'fbs_attachments';

        if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) != $table || $isForced) {
            $sql = "CREATE TABLE $table (
                `id` INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
                `object_id` INT UNSIGNED NOT NULL COMMENT 'Task ID or Comment ID or Board ID',
                `object_type` VARCHAR(100) DEFAULT 'TASK' COMMENT 'TASK|COMMENT|BOARD',
                `attachment_type` VARCHAR(100) NULL,
                `file_path` TEXT NULL,
                `full_url` TEXT NULL,
                `settings` TEXT NULL,
                `title` VARCHAR(192) NULL,
                `file_hash` VARCHAR(192) NULL,
                `driver` VARCHAR(100) DEFAULT 'local',
                `status` VARCHAR(100) NULL DEFAULT 'ACTIVE' COMMENT 'ACTIVE|INACTIVE|DELETED',
                `file_size` VARCHAR(100) NULL,
                `created_at` TIMESTAMP NULL,
                `updated_at` TIMESTAMP NULL,
                KEY `object_type` (`object_type`),
                KEY `object_id` (`object_id`),
                KEY `attachment_type` (`attachment_type`),
                KEY `status` (`status`),
                KEY `file_hash` (`file_hash`),
                KEY `driver` (`driver`)
            ) $charsetCollate;";
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
            dbDelta($sql);
        }
    }
}

```
