CREATE TABLE `tblnote_files` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `note_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
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `tblnote_files`
  ADD PRIMARY KEY (`id`),
  ADD KEY `note_id` (`note_id`);

ALTER TABLE `tblnote_files`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;



ALTER TABLE `tbltask_files` ADD `rel_id` BIGINT(20) UNSIGNED NOT NULL AFTER `id`;
ALTER TABLE `tblnote_files` ADD `rel_id` BIGINT(20) UNSIGNED NOT NULL AFTER `id`;