-- For estimate file upload
INSERT INTO `tblapad_options` (`id`, `type`, `name`, `value`, `autoload`) VALUES 
(NULL, 'estimate_image_files', 'allowed_file_extention', '{\"image\": [\"jpeg\", \"jpg\", \"png\", \"gif\"]}', '1');

INSERT INTO `tblapad_options` (`id`, `type`, `name`, `value`, `autoload`) VALUES (NULL, 'estimate_image_files', 'allowed_file_size', '5120', '1');

CREATE TABLE `tblestimate_image_files` (
    `id` bigint(20) UNSIGNED PRIMARY KEY AUTO_INCREMENT NOT NULL,
    `estimate_id` bigint(20) UNSIGNED DEFAULT NULL,
    `file_name` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
    `filetype` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
    `visible_to_customer` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
    `attachment_key` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `external` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
    `external_link` text COLLATE utf8_unicode_ci DEFAULT NULL,
    `thumbnail_link` text COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'For external usage',
    `original_file_name` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
    `dateadded` datetime NOT NULL
);
ALTER TABLE `tblestimate_image_files` ADD `title` VARCHAR(255) NULL DEFAULT NULL AFTER `file_name`, ADD `description` LONGTEXT NULL DEFAULT NULL AFTER `title`;

-- For invoice file upload
INSERT INTO `tblapad_options` (`id`, `type`, `name`, `value`, `autoload`) VALUES 
(NULL, 'invoice_image_files', 'allowed_file_extention', '{\"image\": [\"jpeg\", \"jpg\", \"png\", \"gif\"]}', '1');

INSERT INTO `tblapad_options` (`id`, `type`, `name`, `value`, `autoload`) VALUES (NULL, 'invoice_image_files', 'allowed_file_size', '5120', '1');

CREATE TABLE `tblinvoice_image_files` (
    `id` bigint(20) UNSIGNED PRIMARY KEY AUTO_INCREMENT NOT NULL,
    `invoice_id` bigint(20) UNSIGNED DEFAULT NULL,
    `file_name` varchar(191) COLLATE utf8_unicode_ci NOT NULL,
    `filetype` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
    `visible_to_customer` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
    `attachment_key` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `external` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
    `external_link` text COLLATE utf8_unicode_ci DEFAULT NULL,
    `thumbnail_link` text COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'For external usage',
    `original_file_name` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
    `dateadded` datetime NOT NULL
);
ALTER TABLE `tblinvoice_image_files` ADD `title` VARCHAR(255) NULL DEFAULT NULL AFTER `file_name`, ADD `description` LONGTEXT NULL DEFAULT NULL AFTER `title`;