| 123456789101112131415161718192021222324252627 |
- USE inventory_db;
- CREATE TABLE IF NOT EXISTS rental_prices (
- id INT(11) AUTO_INCREMENT PRIMARY KEY,
- item_id INT(11) NOT NULL,
- start_date DATE NOT NULL,
- end_date DATE NOT NULL,
- daily_price DECIMAL(10,2) NOT NULL DEFAULT 0.00,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE,
- INDEX idx_item_dates (item_id, start_date, end_date)
- );
- CREATE TABLE IF NOT EXISTS attachments (
- id INT(11) AUTO_INCREMENT PRIMARY KEY,
- item_id INT(11) NOT NULL,
- filename VARCHAR(255) NOT NULL,
- original_name VARCHAR(255) NOT NULL,
- file_type ENUM('receipt', 'warranty', 'other') NOT NULL DEFAULT 'other',
- file_path VARCHAR(255) NOT NULL,
- file_size INT(11) NOT NULL,
- mime_type VARCHAR(100) NOT NULL,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE,
- INDEX idx_item_type (item_id, file_type)
- );
|