-- phpMyAdmin SQL Dump -- version 5.2.1deb1+deb12u1 -- https://www.phpmyadmin.net/ -- -- Host: localhost:3306 -- Generation Time: Dec 21, 2025 at 06:50 AM -- Server version: 10.11.14-MariaDB-0+deb12u2 -- PHP Version: 8.2.29 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: `cbd420` -- -- -------------------------------------------------------- -- -- Table structure for table `buyers` -- CREATE TABLE `buyers` ( `id` int(11) NOT NULL, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `created_at` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `deliveries` -- CREATE TABLE `deliveries` ( `id` int(11) NOT NULL, `sale_id` int(11) NOT NULL, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `status` text NOT NULL DEFAULT 'Pending' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `drops` -- CREATE TABLE `drops` ( `id` int(11) NOT NULL, `item` text NOT NULL, `size` int(11) NOT NULL DEFAULT 100, `fill` int(11) NOT NULL DEFAULT 0, `unit` varchar(12) NOT NULL DEFAULT 'g', `image_url` varchar(255) DEFAULT NULL, `ppu` int(11) NOT NULL DEFAULT 1, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `start_time` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `pending_orders` -- CREATE TABLE `pending_orders` ( `id` int(11) NOT NULL, `payment_id` varchar(255) NOT NULL, `order_id` varchar(255) NOT NULL, `drop_id` int(11) NOT NULL, `buyer_id` int(11) NOT NULL, `size` int(11) NOT NULL, `price_amount` decimal(10,2) NOT NULL, `price_currency` varchar(10) NOT NULL DEFAULT 'chf', `created_at` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `sales` -- CREATE TABLE `sales` ( `id` int(11) NOT NULL, `drop_id` int(11) NOT NULL, `buyer_id` int(11) NOT NULL, `size` int(11) NOT NULL DEFAULT 1, `payment_id` text NOT NULL DEFAULT '', `created_at` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Indexes for dumped tables -- -- -- Indexes for table `buyers` -- ALTER TABLE `buyers` ADD PRIMARY KEY (`id`); -- -- Indexes for table `deliveries` -- ALTER TABLE `deliveries` ADD PRIMARY KEY (`id`), ADD KEY `sale_id` (`sale_id`); -- -- Indexes for table `drops` -- ALTER TABLE `drops` ADD PRIMARY KEY (`id`); -- -- Indexes for table `pending_orders` -- ALTER TABLE `pending_orders` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `payment_id` (`payment_id`), ADD UNIQUE KEY `order_id` (`order_id`), ADD KEY `drop_id` (`drop_id`), ADD KEY `buyer_id` (`buyer_id`); -- -- Indexes for table `sales` -- ALTER TABLE `sales` ADD PRIMARY KEY (`id`), ADD KEY `drop_id` (`drop_id`), ADD KEY `buyer_id` (`buyer_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `buyers` -- ALTER TABLE `buyers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `deliveries` -- ALTER TABLE `deliveries` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `drops` -- ALTER TABLE `drops` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `pending_orders` -- ALTER TABLE `pending_orders` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `sales` -- ALTER TABLE `sales` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- Constraints for dumped tables -- -- -- Constraints for table `deliveries` -- ALTER TABLE `deliveries` ADD CONSTRAINT `deliveries_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `sales` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `pending_orders` -- ALTER TABLE `pending_orders` ADD CONSTRAINT `pending_orders_ibfk_1` FOREIGN KEY (`drop_id`) REFERENCES `drops` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `pending_orders_ibfk_2` FOREIGN KEY (`buyer_id`) REFERENCES `buyers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `sales` -- ALTER TABLE `sales` ADD CONSTRAINT `sales_ibfk_1` FOREIGN KEY (`drop_id`) REFERENCES `drops` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `sales_ibfk_2` FOREIGN KEY (`buyer_id`) REFERENCES `buyers` (`id`) ON DELETE CASCADE ON UPDATE 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 */;