-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Feb 23, 2026 at 05:36 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `spareparts_db`
--

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

--
-- Table structure for table `activity_log`
--

CREATE TABLE `activity_log` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(50) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `icon` varchar(50) DEFAULT 'mdi-information',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `activity_log`
--

INSERT INTO `activity_log` (`id`, `user_id`, `action`, `description`, `icon`, `created_at`) VALUES
(1, 1, 'Add Material Group', 'Added group: AIR CONDITIONER', 'mdi-group', '2026-02-18 19:38:43'),
(2, 1, 'Edit Material Group', 'Updated group: AIR CONDITIONER1', 'mdi-pencil', '2026-02-18 19:38:59'),
(3, 1, 'Delete Material Group', 'Deleted group ID: 5', 'mdi-delete', '2026-02-18 19:39:08'),
(4, 1, 'Add Material Group', 'Added group: AIR CONDITIONER', 'mdi-group', '2026-02-18 19:39:45'),
(5, 1, 'Add Location', 'Added location: Otomotif parts', 'mdi-map-marker', '2026-02-18 19:55:46'),
(6, 1, 'Edit Location', 'Updated location: Warehouse A12', 'mdi-pencil', '2026-02-18 19:56:08'),
(7, 1, 'Delete Location', 'Deleted location ID: 4', 'mdi-delete', '2026-02-18 20:09:40'),
(8, 1, 'Delete Location', 'Deleted location ID: 5', 'mdi-delete', '2026-02-18 20:10:46'),
(9, 1, 'Add Category', 'Added category: BEARING', 'mdi-folder', '2026-02-18 20:22:40'),
(10, 1, 'Add Category', 'Added category: Tes2', 'mdi-folder', '2026-02-19 05:08:26'),
(11, 1, 'Delete Category', 'Deleted category ID: 10', 'mdi-delete', '2026-02-19 05:10:41'),
(12, 1, 'Add Category', 'Added category: tes', 'mdi-folder', '2026-02-19 05:15:30'),
(13, 1, 'Add Location', 'Added location: Tessd', 'mdi-map-marker', '2026-02-19 05:16:02'),
(14, 1, 'Delete Location', 'Deleted location ID: 6', 'mdi-delete', '2026-02-19 05:16:15'),
(15, 1, 'Delete Category', 'Deleted category ID: 11', 'mdi-delete', '2026-02-19 05:31:34');

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

--
-- Table structure for table `bagian_mesin`
--

CREATE TABLE `bagian_mesin` (
  `id` int(11) NOT NULL,
  `mesin_id` int(11) NOT NULL,
  `nama_bagian` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `category`
--

CREATE TABLE `category` (
  `id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `category`
--

INSERT INTO `category` (`id`, `code`, `name`, `description`, `status`, `created_at`, `updated_at`) VALUES
(1, 'MECH', 'Mechanical', 'Mechanical parts and components', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35'),
(2, 'ELEC', 'Electrical', 'Electrical components and wiring', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35'),
(3, 'HYD', 'Hydraulic', 'Hydraulic system parts', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35'),
(4, 'PNEU', 'Pneumatic', 'Pneumatic system components', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35'),
(5, 'CONS', 'Consumables', 'Consumable items and supplies', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35'),
(9, 'BRG', 'BEARING', 'Bearing', 'active', '2026-02-18 20:22:40', '2026-02-18 20:22:40');

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

--
-- Table structure for table `goods_receipt_items`
--

CREATE TABLE `goods_receipt_items` (
  `id` int(11) NOT NULL,
  `po_number` varchar(50) DEFAULT NULL,
  `part_number` varchar(50) NOT NULL,
  `item_name` varchar(200) NOT NULL,
  `qty` int(11) NOT NULL,
  `unit` varchar(20) DEFAULT NULL,
  `price` decimal(15,2) DEFAULT 0.00,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `goods_receipt_items`
--

INSERT INTO `goods_receipt_items` (`id`, `po_number`, `part_number`, `item_name`, `qty`, `unit`, `price`, `created_at`) VALUES
(1, '2', 'BP-001', 'Bearing 6205', 1, 'PC', 150000.00, '2026-02-19 21:10:04'),
(2, 'PO-202601-0001', 'BP-001', 'Bearing 6205', 1, 'PC', 150000.00, '2026-02-19 21:53:36'),
(3, 'PO-202601-0001', 'BP-001', 'Bearing 6205', 1, 'PC', 150000.00, '2026-02-19 22:14:34'),
(4, 'PO-202601-0001', 'BP-001', 'Bearing 6205 2rs', 1, 'PC', 150000.00, '2026-02-19 23:17:04'),
(5, 'PO-202601-0001', 'BP-001', 'Bearing 6205', 9, 'PC', 150000.00, '2026-02-19 23:18:13'),
(6, 'PO-202601-0001', 'BP-001', 'Bearing 6205', 1, 'PC', 150000.00, '2026-02-19 23:18:25');

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

--
-- Table structure for table `lines`
--

CREATE TABLE `lines` (
  `id` int(11) NOT NULL,
  `nama_line` varchar(100) NOT NULL,
  `nama_product` varchar(150) NOT NULL,
  `mesin_id` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `locations`
--

CREATE TABLE `locations` (
  `id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL,
  `building` varchar(50) DEFAULT NULL,
  `floor` varchar(20) DEFAULT NULL,
  `area` varchar(50) DEFAULT NULL,
  `max_capacity` int(11) DEFAULT 100,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `locations`
--

INSERT INTO `locations` (`id`, `code`, `name`, `building`, `floor`, `area`, `max_capacity`, `status`, `created_at`, `updated_at`) VALUES
(1, 'WH-A12', 'Warehouse A12', 'Building A2', '12', 'East Wing2', 5002, 'active', '2026-02-18 18:04:35', '2026-02-18 19:56:08'),
(2, 'WH-A2', 'Warehouse A2', 'Building A', '2', 'West Wing', 300, 'active', '2026-02-18 18:04:35', '2026-02-18 19:45:22'),
(3, 'WH-B1', 'Warehouse B1', 'Building B', '1', 'North Wing', 200, 'active', '2026-02-18 18:04:35', '2026-02-18 19:45:22');

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

--
-- Table structure for table `material_group`
--

CREATE TABLE `material_group` (
  `id` int(11) NOT NULL,
  `code` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `material_group`
--

INSERT INTO `material_group` (`id`, `code`, `name`, `description`, `status`, `created_at`, `updated_at`) VALUES
(1, 'MAN', 'MECHANICAL', 'Mechanical material components', 'active', '2026-02-18 18:04:35', '2026-02-18 19:03:55'),
(2, 'GEN', 'GENERAL', 'General use material', 'active', '2026-02-18 18:04:35', '2026-02-18 19:04:26'),
(3, 'OTO', 'OTOMOTIF', 'Otomotif material', 'active', '2026-02-18 18:04:35', '2026-02-18 19:04:38'),
(4, 'ELE', 'ELECTRICAL', 'Electrical material', 'active', '2026-02-18 18:04:35', '2026-02-18 19:04:53'),
(6, 'A/C', 'AIR CONDITIONER', 'Air conditioner material us', 'active', '2026-02-18 19:39:45', '2026-02-18 19:39:45');

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

--
-- Table structure for table `mesin`
--

CREATE TABLE `mesin` (
  `id` int(11) NOT NULL,
  `nama_mesin` varchar(100) NOT NULL,
  `tahun` year(4) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `mesin`
--

INSERT INTO `mesin` (`id`, `nama_mesin`, `tahun`, `created_at`) VALUES
(3, 'interfolder', '2025', '2026-02-21 01:06:56');

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

--
-- Table structure for table `purchase_orders`
--

CREATE TABLE `purchase_orders` (
  `id` int(11) NOT NULL,
  `po_number` varchar(50) NOT NULL,
  `date` date NOT NULL,
  `supplier_name` varchar(150) DEFAULT NULL,
  `status` enum('pending','partial','completed','cancelled') DEFAULT 'pending',
  `comments` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `purchase_orders`
--

INSERT INTO `purchase_orders` (`id`, `po_number`, `date`, `supplier_name`, `status`, `comments`, `created_at`) VALUES
(6, 'PO-202601-0001', '2026-02-20', 'ALI', 'completed', '', '2026-02-19 23:07:18');

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

--
-- Table structure for table `purchase_order_items`
--

CREATE TABLE `purchase_order_items` (
  `id` int(11) NOT NULL,
  `po_id` int(11) NOT NULL,
  `item_code` varchar(50) NOT NULL,
  `item_name` varchar(200) NOT NULL,
  `qty` decimal(15,2) NOT NULL DEFAULT 0.00,
  `unit` varchar(20) DEFAULT NULL,
  `price` decimal(15,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `spareparts`
--

CREATE TABLE `spareparts` (
  `id` int(11) NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `name` varchar(200) NOT NULL,
  `description` text DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `location_id` int(11) DEFAULT NULL,
  `material_group_id` int(11) DEFAULT NULL,
  `stock` int(11) DEFAULT 0,
  `min_stock` int(11) DEFAULT 5,
  `max_stock` int(11) DEFAULT 100,
  `unit` varchar(20) DEFAULT 'pcs',
  `price` decimal(15,2) DEFAULT 0.00,
  `machine_type` varchar(100) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `spareparts`
--

INSERT INTO `spareparts` (`id`, `part_number`, `name`, `description`, `category_id`, `location_id`, `material_group_id`, `stock`, `min_stock`, `max_stock`, `unit`, `price`, `machine_type`, `image`, `status`, `created_at`, `updated_at`) VALUES
(1, 'BP-001', 'Bearing 6205', 'Deep groove ball bearing', 1, 1, 3, 14, 10, 100, 'PC', 150000.00, 'Rewinder', NULL, 'active', '2026-02-18 18:04:35', '2026-02-19 23:18:25'),
(2, 'BP-002', 'Bearing 6206', 'Deep groove ball bearing', 1, 1, 3, 0, 10, 100, 'PC', 175000.00, 'Rewinder', NULL, 'active', '2026-02-18 18:04:35', '2026-02-19 20:54:35'),
(3, 'BLT-001', 'Belt V-A42', 'V-belt for main drive', 1, 2, 3, 0, 5, 50, 'PC', 250000.00, 'Converting', NULL, 'active', '2026-02-18 18:04:35', '2026-02-19 20:54:40'),
(4, 'MTR-001', 'Motor 5kW', 'AC induction motor', 2, 3, 3, 0, 1, 10, 'PC', 5000000.00, 'Main Drive', NULL, 'active', '2026-02-18 18:04:35', '2026-02-19 20:54:46');

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

--
-- Table structure for table `sparepart_history`
--

CREATE TABLE `sparepart_history` (
  `id` int(11) NOT NULL,
  `part_number` varchar(50) NOT NULL,
  `name_barang` varchar(100) NOT NULL,
  `old_value` text DEFAULT NULL,
  `new_value` text DEFAULT NULL,
  `qty` int(4) NOT NULL,
  `status` text DEFAULT NULL,
  `doc` varchar(50) DEFAULT NULL,
  `changed_by` int(11) DEFAULT NULL,
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sparepart_history`
--

INSERT INTO `sparepart_history` (`id`, `part_number`, `name_barang`, `old_value`, `new_value`, `qty`, `status`, `doc`, `changed_by`, `changed_at`) VALUES
(1, '1', 'Bearing 6205', '0', '1', 0, 'GOOD RECEIVE', '2', 1, '2026-02-19 21:10:04'),
(3, 'BP-001', 'Bearing 6205', '150000', '150000', 1, 'GOOD RECEIVE', 'PO-202601-0001', 1, '2026-02-19 21:53:36'),
(4, 'BP-001', 'Bearing 6205', '150000', '150000', 1, 'GOOD RECEIVE', 'PO-202601-0001', 1, '2026-02-19 22:14:34'),
(5, 'BP-001', 'Bearing 6205 2rs', '150000', '150000', 1, 'GOOD RECEIVE', 'PO-202601-0001', 1, '2026-02-19 23:17:04'),
(6, 'BP-001', 'Bearing 6205', '150000', '150000', 9, 'GOOD RECEIVE', 'PO-202601-0001', 1, '2026-02-19 23:18:13'),
(7, 'BP-001', 'Bearing 6205', '150000', '150000', 1, 'GOOD RECEIVE', 'PO-202601-0001', 1, '2026-02-19 23:18:25');

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

--
-- Table structure for table `sparepart_images`
--

CREATE TABLE `sparepart_images` (
  `id` int(11) NOT NULL,
  `sparepart_id` int(11) NOT NULL,
  `image_path` varchar(255) NOT NULL,
  `image_hash` varchar(64) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sparepart_images`
--

INSERT INTO `sparepart_images` (`id`, `sparepart_id`, `image_path`, `image_hash`, `created_at`) VALUES
(12, 2, '6996745879550_1771467864.jpg', '3f769b9f9f9f1f4f', '2026-02-19 02:24:24'),
(13, 1, '699764a1603f3_1771529377.png', '05441a1a181d1c30', '2026-02-19 19:29:37'),
(14, 1, '699764a19840f_1771529377.png', 'ac4140c0e0c0c070', '2026-02-19 19:29:37');

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

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `full_name` varchar(100) NOT NULL,
  `email` varchar(100) DEFAULT NULL,
  `role` enum('admin','maintenance','guest') DEFAULT 'guest',
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `theme` varchar(20) DEFAULT 'black',
  `lang` varchar(10) DEFAULT 'id',
  `text_size` varchar(5) DEFAULT 'm',
  `btn_size` varchar(5) DEFAULT 'm',
  `icon_size` varchar(5) DEFAULT 'm'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `username`, `password`, `full_name`, `email`, `role`, `status`, `created_at`, `updated_at`, `theme`, `lang`, `text_size`, `btn_size`, `icon_size`) VALUES
(1, 'admin', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Administrator', 'admin@company.com', 'admin', 'active', '2026-02-18 18:04:35', '2026-02-21 01:08:03', 'black', 'en', 'xs', 'xs', 'xs'),
(2, 'maintenance', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Maintenance Team', 'maintenance@company.com', 'maintenance', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35', 'black', 'id', 'm', 'm', 'm'),
(3, 'guest', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Guest User', 'guest@company.com', 'guest', 'active', '2026-02-18 18:04:35', '2026-02-18 18:04:35', 'black', 'id', 'm', 'm', 'm');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activity_log`
--
ALTER TABLE `activity_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `bagian_mesin`
--
ALTER TABLE `bagian_mesin`
  ADD PRIMARY KEY (`id`),
  ADD KEY `mesin_id` (`mesin_id`);

--
-- Indexes for table `category`
--
ALTER TABLE `category`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

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

--
-- Indexes for table `lines`
--
ALTER TABLE `lines`
  ADD PRIMARY KEY (`id`),
  ADD KEY `mesin_id` (`mesin_id`);

--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `material_group`
--
ALTER TABLE `material_group`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

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

--
-- Indexes for table `purchase_orders`
--
ALTER TABLE `purchase_orders`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `po_number` (`po_number`);

--
-- Indexes for table `purchase_order_items`
--
ALTER TABLE `purchase_order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `po_id` (`po_id`);

--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_key` (`setting_key`);

--
-- Indexes for table `spareparts`
--
ALTER TABLE `spareparts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `part_number` (`part_number`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `location_id` (`location_id`),
  ADD KEY `fk_sparepart_material` (`material_group_id`);

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

--
-- Indexes for table `sparepart_images`
--
ALTER TABLE `sparepart_images`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sparepart_id` (`sparepart_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `activity_log`
--
ALTER TABLE `activity_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `bagian_mesin`
--
ALTER TABLE `bagian_mesin`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `goods_receipt_items`
--
ALTER TABLE `goods_receipt_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

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

--
-- AUTO_INCREMENT for table `locations`
--
ALTER TABLE `locations`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `material_group`
--
ALTER TABLE `material_group`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `mesin`
--
ALTER TABLE `mesin`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `purchase_orders`
--
ALTER TABLE `purchase_orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `purchase_order_items`
--
ALTER TABLE `purchase_order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

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

--
-- AUTO_INCREMENT for table `spareparts`
--
ALTER TABLE `spareparts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `sparepart_history`
--
ALTER TABLE `sparepart_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `sparepart_images`
--
ALTER TABLE `sparepart_images`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `activity_log`
--
ALTER TABLE `activity_log`
  ADD CONSTRAINT `activity_log_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `bagian_mesin`
--
ALTER TABLE `bagian_mesin`
  ADD CONSTRAINT `fk_bagian_mesin` FOREIGN KEY (`mesin_id`) REFERENCES `mesin` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `lines`
--
ALTER TABLE `lines`
  ADD CONSTRAINT `fk_line_mesin` FOREIGN KEY (`mesin_id`) REFERENCES `mesin` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `purchase_order_items`
--
ALTER TABLE `purchase_order_items`
  ADD CONSTRAINT `fk_po_items` FOREIGN KEY (`po_id`) REFERENCES `purchase_orders` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `spareparts`
--
ALTER TABLE `spareparts`
  ADD CONSTRAINT `fk_sparepart_material` FOREIGN KEY (`material_group_id`) REFERENCES `material_group` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `spareparts_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `spareparts_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `spareparts_ibfk_3` FOREIGN KEY (`material_group_id`) REFERENCES `material_group` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `sparepart_images`
--
ALTER TABLE `sparepart_images`
  ADD CONSTRAINT `sparepart_images_ibfk_1` FOREIGN KEY (`sparepart_id`) REFERENCES `spareparts` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
