-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `stock`
--

-- --------------------------------------------------------

--
-- Table structure for table `fault_stock`
--

CREATE TABLE `fault_stock` (
  `id` int(11) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `fault_date` date NOT NULL,
  `given_to` varchar(100) NOT NULL,
  `item_name` varchar(100) NOT NULL,
  `qty` int(11) NOT NULL,
  `remarks` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `particular_name` varchar(255) DEFAULT NULL,
  `specification` varchar(255) DEFAULT NULL,
  `model_number` varchar(255) DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `purchase_stock_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `outward_stock`
--

CREATE TABLE `outward_stock` (
  `id` int(11) NOT NULL,
  `outward_date` date DEFAULT NULL,
  `given_to` varchar(150) DEFAULT NULL,
  `item_name` varchar(100) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `remarks` varchar(200) DEFAULT NULL,
  `particular_name` varchar(255) DEFAULT NULL,
  `specification` varchar(255) DEFAULT NULL,
  `model_number` varchar(255) DEFAULT NULL,
  `os_number` varchar(8) NOT NULL,
  `purchase_stock_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `purchase_invoice`
--

CREATE TABLE `purchase_invoice` (
  `id` int(11) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `invoice_number` varchar(50) DEFAULT NULL,
  `incoming_date` date DEFAULT NULL,
  `courier_name` varchar(100) DEFAULT NULL,
  `courier_charge` decimal(10,2) DEFAULT NULL,
  `total_amount` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `purchase_stock`
--

CREATE TABLE `purchase_stock` (
  `id` int(11) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `invoice_number` varchar(50) DEFAULT NULL,
  `incoming_date` date DEFAULT NULL,
  `courier_name` varchar(100) DEFAULT NULL,
  `item_name` varchar(100) DEFAULT NULL,
  `particular_name` varchar(100) DEFAULT NULL,
  `specification` varchar(100) DEFAULT NULL,
  `model_number` varchar(50) DEFAULT NULL,
  `qty` decimal(10,2) DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `gst` decimal(10,2) DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `fault_count` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `fault_stock`
--
ALTER TABLE `fault_stock`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_fault_purchase` (`purchase_stock_id`);

--
-- Indexes for table `outward_stock`
--
ALTER TABLE `outward_stock`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `os_number` (`os_number`),
  ADD KEY `fk_outward_purchase` (`purchase_stock_id`);

--
-- Indexes for table `purchase_invoice`
--
ALTER TABLE `purchase_invoice`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `purchase_invoice` ADD FULLTEXT KEY `invoice_number` (`invoice_number`);

--
-- Indexes for table `purchase_stock`
--
ALTER TABLE `purchase_stock`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `fault_stock`
--
ALTER TABLE `fault_stock`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `outward_stock`
--
ALTER TABLE `outward_stock`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `purchase_invoice`
--
ALTER TABLE `purchase_invoice`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `purchase_stock`
--
ALTER TABLE `purchase_stock`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `fault_stock`
--
ALTER TABLE `fault_stock`
  ADD CONSTRAINT `fk_fault_purchase` FOREIGN KEY (`purchase_stock_id`) REFERENCES `purchase_stock` (`id`);

--
-- Constraints for table `outward_stock`
--
ALTER TABLE `outward_stock`
  ADD CONSTRAINT `fk_outward_purchase` FOREIGN KEY (`purchase_stock_id`) REFERENCES `purchase_stock` (`id`);
COMMIT;

