cmc-sales/go-app/sql/schema/enquiries.sql

57 lines
2.1 KiB
MySQL
Raw Normal View History

2025-06-24 03:32:28 -07:00
-- Enquiries table schema
CREATE TABLE `enquiries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL,
`submitted` date DEFAULT NULL,
`title` varchar(255) NOT NULL COMMENT 'enquirynumber',
`user_id` int(11) NOT NULL,
`customer_id` int(11) NOT NULL,
`contact_id` int(11) NOT NULL,
`contact_user_id` int(11) NOT NULL,
`state_id` int(11) NOT NULL,
`country_id` int(11) NOT NULL,
`principle_id` int(11) NOT NULL,
`status_id` int(11) NOT NULL,
`comments` text NOT NULL,
`principle_code` int(3) NOT NULL COMMENT 'Numeric Principle Code',
`gst` tinyint(1) NOT NULL COMMENT 'GST applicable on this enquiry',
`billing_address_id` int(11) DEFAULT NULL,
`shipping_address_id` int(11) DEFAULT NULL,
`posted` tinyint(1) NOT NULL COMMENT 'has the enquired been posted',
`email_count` int(11) NOT NULL DEFAULT 0,
`invoice_count` int(11) NOT NULL DEFAULT 0,
`job_count` int(11) NOT NULL DEFAULT 0,
`quote_count` int(11) NOT NULL DEFAULT 0,
`archived` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17101 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
-- Related tables for foreign key references
CREATE TABLE `statuses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`color` varchar(7) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
CREATE TABLE `principles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`short_name` varchar(50) DEFAULT NULL,
`code` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
CREATE TABLE `states` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`shortform` varchar(20) DEFAULT NULL,
`enqform` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
CREATE TABLE `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;