23 lines
1.1 KiB
SQL
23 lines
1.1 KiB
SQL
-- Documents table schema (matches actual production database)
|
|
CREATE TABLE `documents` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`type` enum('quote','invoice','purchaseOrder','orderAck','packingList') NOT NULL,
|
|
`created` datetime NOT NULL,
|
|
`user_id` int(11) NOT NULL,
|
|
`doc_page_count` int(11) NOT NULL,
|
|
`cmc_reference` varchar(255) NOT NULL COMMENT 'Either the Enquiry number, Invoice no, order ack. Convenient place to store this to save on queries',
|
|
`pdf_filename` varchar(255) NOT NULL,
|
|
`pdf_created_at` datetime NOT NULL,
|
|
`pdf_created_by_user_id` int(11) NOT NULL,
|
|
`shipping_details` text DEFAULT NULL,
|
|
`revision` int(11) NOT NULL DEFAULT 0,
|
|
`bill_to` text DEFAULT NULL,
|
|
`ship_to` text DEFAULT NULL,
|
|
`email_sent_at` datetime NOT NULL,
|
|
`email_sent_by_user_id` int(11) NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `idx_documents_type` (`type`),
|
|
KEY `idx_documents_created` (`created`),
|
|
KEY `idx_documents_user_id` (`user_id`),
|
|
KEY `idx_documents_cmc_reference` (`cmc_reference`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |