-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: May 09, 2026 at 04:58 AM
-- Server version: 10.11.16-MariaDB-cll-lve
-- PHP Version: 8.4.20

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: `hostku8374_rekapin`
--

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

--
-- Table structure for table `budgets`
--

CREATE TABLE `budgets` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `category` varchar(100) NOT NULL,
  `amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `period` enum('monthly','weekly','yearly') DEFAULT 'monthly',
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `budgets`
--

INSERT INTO `budgets` (`id`, `user_id`, `category`, `amount`, `period`, `created_at`) VALUES
(2, 24, 'Belanja Bulanan', 50000.00, 'monthly', '2026-05-07 15:57:02');

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

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `type` enum('income','expense') NOT NULL,
  `icon` varchar(50) DEFAULT '?',
  `color` varchar(20) DEFAULT '#6366F1',
  `is_default` tinyint(1) DEFAULT 0,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `user_id`, `name`, `type`, `icon`, `color`, `is_default`, `created_at`) VALUES
(1, 24, 'Makanan & Minuman', 'expense', '🍔', '#F43F5E', 1, '2026-05-06 16:42:47'),
(2, 24, 'Transportasi', 'expense', '🚗', '#3B82F6', 1, '2026-05-06 16:42:47'),
(3, 24, 'Tagihan', 'expense', '📄', '#F59E0B', 1, '2026-05-06 16:42:47'),
(4, 24, 'Belanja Bulanan', 'expense', '🛒', '#8B5CF6', 1, '2026-05-06 16:42:47'),
(5, 24, 'Hobi & Hiburan', 'expense', '🎮', '#EC4899', 1, '2026-05-06 16:42:47'),
(6, 24, 'Kesehatan', 'expense', '💊', '#10B981', 1, '2026-05-06 16:42:47'),
(7, 24, 'Lainnya', 'expense', '📦', '#64748B', 1, '2026-05-06 16:42:47'),
(8, 24, 'Gaji', 'income', '💰', '#10B981', 1, '2026-05-06 16:42:47'),
(9, 24, 'Freelance', 'income', '💻', '#3B82F6', 1, '2026-05-06 16:42:47'),
(10, 24, 'Investasi', 'income', '📈', '#8B5CF6', 1, '2026-05-06 16:42:47'),
(11, 24, 'Hadiah', 'income', '🎁', '#EC4899', 1, '2026-05-06 16:42:47'),
(12, 24, 'Bonus', 'income', '⭐', '#F59E0B', 1, '2026-05-06 16:42:47'),
(13, 24, 'Lainnya', 'income', '📦', '#64748B', 1, '2026-05-06 16:42:47'),
(27, 24, 'Shopping', 'expense', '🛍️', '#6366f1', 0, '2026-05-06 17:01:18'),
(28, 24, 'Gift', 'expense', '🎁', '#6366f1', 0, '2026-05-06 17:06:42');

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

--
-- Table structure for table `collaborators`
--

CREATE TABLE `collaborators` (
  `id` int(11) NOT NULL,
  `owner_user_id` int(11) NOT NULL,
  `collaborator_chat_id` varchar(50) NOT NULL,
  `collaborator_name` varchar(100) DEFAULT 'Kolaborator',
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `debts`
--

CREATE TABLE `debts` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `type` enum('hutang','piutang') NOT NULL,
  `person_name` varchar(100) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `paid_amount` decimal(15,2) DEFAULT 0.00,
  `description` text DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `status` enum('active','paid','overdue') DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `debts`
--

INSERT INTO `debts` (`id`, `user_id`, `type`, `person_name`, `amount`, `paid_amount`, `description`, `due_date`, `status`, `created_at`, `updated_at`) VALUES
(2, 24, 'piutang', 'Delvi', 500000.00, 0.00, '', '2026-06-13', 'active', '2026-05-06 17:13:25', '2026-05-06 17:13:25'),
(3, 24, 'piutang', 'Maulana', 3100000.00, 0.00, '', '2027-05-01', 'active', '2026-05-09 02:32:45', '2026-05-09 02:32:45');

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

--
-- Table structure for table `logs`
--

CREATE TABLE `logs` (
  `id` int(11) NOT NULL,
  `msgid` int(11) NOT NULL,
  `chatid` varchar(255) NOT NULL,
  `text` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `logs`
--

INSERT INTO `logs` (`id`, `msgid`, `chatid`, `text`) VALUES
(1, 465, '6310843350', 'bantuan_menu'),
(2, 467, '6310843350', ''),
(3, 470, '6310843350', ''),
(4, 471, '6310843350', 'laporan_menu'),
(5, 479, '6310843350', ''),
(6, 483, '6495353594', 'laporan_menu'),
(7, 484, '6310843350', ''),
(8, 495, '6310843350', ''),
(9, 500, '6310843350', 'laporan_menu'),
(10, 501, '6310843350', 'bantuan_menu');

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

--
-- Table structure for table `members`
--

CREATE TABLE `members` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `avatar_color` varchar(20) DEFAULT '#6366F1',
  `telegram_chat_id` varchar(50) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `members`
--

INSERT INTO `members` (`id`, `user_id`, `name`, `avatar_color`, `telegram_chat_id`, `created_at`) VALUES
(1, 24, 'Vinz', '#0af587', NULL, '2026-04-27 04:31:24'),
(2, 24, 'Intan', '#14b8a6', NULL, '2026-05-06 16:24:03'),
(3, 24, 'Maulana', '#6366f1', NULL, '2026-05-06 16:24:46'),
(4, 24, 'Delvi', '#8b5cf6', NULL, '2026-05-06 16:56:33');

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

--
-- Table structure for table `recurring_transactions`
--

CREATE TABLE `recurring_transactions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `store` varchar(255) NOT NULL,
  `total` decimal(15,2) NOT NULL,
  `items` text DEFAULT NULL,
  `category` varchar(50) NOT NULL,
  `type` enum('Pemasukan','Pengeluaran') NOT NULL,
  `wallet_id` int(11) DEFAULT NULL,
  `member_id` int(11) DEFAULT NULL,
  `frequency` enum('daily','weekly','monthly','yearly') NOT NULL DEFAULT 'monthly',
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `note` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `savings_goals`
--

CREATE TABLE `savings_goals` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `target_amount` decimal(15,2) NOT NULL,
  `current_amount` decimal(15,2) DEFAULT 0.00,
  `icon` varchar(50) DEFAULT '?',
  `color` varchar(20) DEFAULT '#10B981',
  `deadline` date DEFAULT NULL,
  `status` enum('active','completed','cancelled') DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `savings_goals`
--

INSERT INTO `savings_goals` (`id`, `user_id`, `name`, `target_amount`, `current_amount`, `icon`, `color`, `deadline`, `status`, `created_at`, `updated_at`) VALUES
(1, 24, 'Nikah', 1000000.00, 101000.00, '🎯', '#10b981', '2028-05-13', 'active', '2026-05-06 17:50:18', '2026-05-07 17:31:16');

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

--
-- Table structure for table `transactions`
--

CREATE TABLE `transactions` (
  `id` int(11) NOT NULL,
  `uid` char(36) NOT NULL,
  `user_id` int(11) NOT NULL,
  `member_id` int(11) DEFAULT NULL,
  `wallet_id` int(11) DEFAULT NULL,
  `store` varchar(255) NOT NULL DEFAULT 'Manual Input',
  `total` decimal(15,2) NOT NULL CHECK (`total` > 0),
  `items` text DEFAULT NULL,
  `note` text DEFAULT NULL,
  `category` varchar(50) DEFAULT NULL,
  `type` enum('Pemasukan','Pengeluaran') NOT NULL,
  `receipt_date` date NOT NULL,
  `input_date` date NOT NULL DEFAULT current_timestamp(),
  `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_general_ci;

--
-- Dumping data for table `transactions`
--

INSERT INTO `transactions` (`id`, `uid`, `user_id`, `member_id`, `wallet_id`, `store`, `total`, `items`, `note`, `category`, `type`, `receipt_date`, `input_date`, `created_at`, `updated_at`) VALUES
(83, '972ddb16-5c20-46c9-bd17-b5acb48126e1', 24, 1, 1, 'Gajian', 9500000.00, '', '', 'Gaji', 'Pemasukan', '2026-05-01', '2026-05-08', '2026-05-08 02:07:14', '2026-05-09 02:48:01'),
(84, 'mom93474-2wdb9w6', 24, 2, 1, 'FLIP', 15560.00, 'DOKU', 'FLIP-DOKU', 'Lainnya', 'Pengeluaran', '2026-05-01', '2026-05-08', '2026-05-08 02:07:35', '2026-05-08 04:02:44'),
(85, 'mop8l89s-2wdb9w6', 24, NULL, 1, 'Transfer ke BCA Virtual Account', 405800.00, '-', 'Transfer ke BCA Virtual Account--', 'Lainnya', 'Pengeluaran', '2026-05-03', '2026-05-08', '2026-05-08 02:07:35', '2026-05-08 04:02:42'),
(86, 'mopzfyqo-2wdb9w6', 24, NULL, 1, 'HASMITA', 650000.00, '1980219093', 'HASMITA-1980219093', 'Lainnya', 'Pengeluaran', '2026-05-03', '2026-05-08', '2026-05-08 02:07:35', '2026-05-08 04:02:42'),
(87, 'movdif34-2wdb9w6', 24, NULL, 1, 'Transfer ke BCA Virtual Account', 301000.00, '-', 'Transfer ke BCA Virtual Account--', 'Lainnya', 'Pengeluaran', '2026-05-07', '2026-05-08', '2026-05-08 02:07:35', '2026-05-08 04:02:44'),
(88, 'mow0u9nk-2wdb9w6', 24, NULL, 1, 'SITI YUNITA SARI', 20000.00, '5785374841', 'SITI YUNITA SARI-5785374841', 'Lainnya', 'Pengeluaran', '2026-05-07', '2026-05-08', '2026-05-08 02:07:36', '2026-05-08 04:02:44'),
(89, 'mondznrs-2wdb9w6', 24, 1, 1, 'FLIPTECH LENTERA IP PT', 912825.00, '5465389289', 'FLIPTECH LENTERA IP PT-5465389289', 'Lainnya', 'Pengeluaran', '2026-05-01', '2026-05-08', '2026-05-08 02:07:36', '2026-05-08 04:02:44'),
(90, 'moq82pgw-2wdb9w6', 24, NULL, 1, 'MAULANA SYUFI IKBAL', 25000.00, '7560466841', 'MAULANA SYUFI IKBAL-7560466841', 'Lainnya', 'Pengeluaran', '2026-05-03', '2026-05-08', '2026-05-08 02:07:36', '2026-05-08 04:02:43'),
(91, 'mor3jrlc-2wdb9w6', 24, 4, 1, 'FLIPTECH LENTERA IP PT', 500348.00, '5465389289', 'FLIPTECH LENTERA IP PT-5465389289', 'Lainnya', 'Pengeluaran', '2026-05-04', '2026-05-08', '2026-05-08 02:07:36', '2026-05-08 04:02:42'),
(92, 'mosn056w-2wdb9w6', 24, 1, 1, 'Transfer ke BCA Virtual Account', 3241100.00, '-', 'Transfer ke BCA Virtual Account--', 'Lainnya', 'Pengeluaran', '2026-05-05', '2026-05-08', '2026-05-08 02:07:37', '2026-05-08 04:02:43'),
(93, 'mouhbokw-2wdb9w6', 24, 1, 1, 'IDM INDOMARET D', 52200.00, 'BCA', 'IDM INDOMARET D-BCA', 'Lainnya', 'Pengeluaran', '2026-05-06', '2026-05-08', '2026-05-08 02:07:37', '2026-05-08 04:02:43'),
(94, 'mouguop4-2wdb9w6', 24, NULL, 1, 'IOH', 55000.00, 'OTTOCASH', 'IOH-OTTOCASH', 'Lainnya', 'Pengeluaran', '2026-05-06', '2026-05-08', '2026-05-08 02:07:37', '2026-05-08 04:02:43'),
(95, 'mon16748-2wdb9w6', 24, NULL, 1, 'GALAXY RELOAD', 1501.00, 'DANA', 'GALAXY RELOAD-DANA', 'Lainnya', 'Pengeluaran', '2026-05-01', '2026-05-08', '2026-05-08 02:07:37', '2026-05-08 04:02:42'),
(96, 'morh8fpc-2wdb9w6', 24, 1, 2, 'SeaBank Bayar Instan', 11500.00, '-', 'SeaBank Bayar Instan--', 'Lainnya', 'Pengeluaran', '2026-05-04', '2026-05-08', '2026-05-08 02:07:38', '2026-05-08 04:02:46'),
(98, 'tfr-in-1778206308445', 24, NULL, 2, 'Transfer ← BCA', 405800.00, 'Transfer Masuk', '', '', 'Pemasukan', '2026-05-03', '2026-05-08', '2026-05-08 02:11:48', '2026-05-08 02:12:31'),
(100, 'tfr-in-1778206698544', 24, NULL, 3, 'Transfer ← BCA', 301000.00, 'Transfer Masuk', '', 'Transfer', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 02:18:18', '2026-05-08 02:18:18'),
(101, '5b2235b1-7b93-48b1-a55f-e9a2582f8f70', 24, 1, 2, 'Jagoan Hosting', 100000.00, 'VPS', '', 'Belanja Bulanan', 'Pengeluaran', '2026-05-04', '2026-05-08', '2026-05-08 02:19:48', '2026-05-08 02:20:16'),
(102, '6385e600-d1d8-4e94-b842-bc5c8c4d2b0a', 24, 2, 1, 'Bayar Hutang Intan', 15000.00, '', '', 'Freelance', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 02:40:17', '2026-05-08 02:40:17'),
(103, '36b11fbb-8a5f-4d38-93c8-e7bfce37236d', 24, 1, 1, 'Dispenser', 300000.00, 'Patungan Beli Dispenser', '', 'Freelance', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 02:41:29', '2026-05-08 02:41:29'),
(104, 'ddbf058a-9fc5-49d1-845e-2fdd6cf0e3a9', 24, 1, 1, 'Freelance', 451500.00, '', '', 'Freelance', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 02:43:48', '2026-05-08 02:43:48'),
(105, 'c7629eb8-d8b2-4fad-b79e-b75b6680555c', 24, 1, 1, 'Freelance', 750000.00, '', '', 'Freelance', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 02:44:17', '2026-05-08 02:44:17'),
(106, 'mownx45c-2wdb9w6', 24, 1, 2, 'SeaBank Bayar Instan', 20469.00, '-', 'SeaBank Bayar Instan--', 'Lainnya', 'Pengeluaran', '2026-05-08', '2026-05-08', '2026-05-08 04:02:46', '2026-05-08 13:02:48'),
(107, 'moworz9c-2wdb9w6', 24, 1, 2, 'SeaBank Bayar Instan', 21000.00, '-', 'SeaBank Bayar Instan--', 'Lainnya', 'Pengeluaran', '2026-05-08', '2026-05-08', '2026-05-08 04:02:46', '2026-05-08 13:02:48'),
(108, 'mox57new-2wdb9w6', 24, 1, 1, 'MARIA KIRANA', 50000.00, '7570311691', 'MARIA KIRANA-7570311691', 'Lainnya', 'Pengeluaran', '2026-05-08', '2026-05-08', '2026-05-08 10:02:43', '2026-05-08 13:02:45'),
(109, '3f5c8b76-0f02-4364-b88b-409cc152be87', 24, 1, 1, 'Topup Koin Tiktok', 40001.00, 'Intan', '', 'Bonus', 'Pemasukan', '2026-05-08', '2026-05-08', '2026-05-08 12:14:40', '2026-05-08 12:14:40'),
(110, 'moxadfoo-2wdb9w6', 24, 1, 1, 'ALFIN HILMY NURMAKHLUFI', 200000.00, '8035113564', 'ALFIN HILMY NURMAKHLUFI-8035113564', 'Lainnya', 'Pengeluaran', '2026-05-08', '2026-05-08', '2026-05-08 12:15:46', '2026-05-08 13:02:44'),
(111, 'ed6afe09-8b84-4f46-b19f-4d5779df8edb', 24, 1, 3, 'Makan Dinda', 110500.00, '', '', 'Belanja Bulanan', 'Pengeluaran', '2026-05-07', '2026-05-08', '2026-05-08 12:19:05', '2026-05-08 12:19:05'),
(112, '301d4d0c-59df-4803-90fc-9dabdafda685', 24, 1, 3, 'Makan Dinda', 34600.00, '', '', 'Makanan & Minuman', 'Pengeluaran', '2026-05-08', '2026-05-08', '2026-05-08 12:19:59', '2026-05-08 12:19:59'),
(113, 'moxmcecg-2wdb9w6', 24, 1, 1, 'FLIPTECH LENTERA IP PT', 2098325.00, '5465128965', '', 'Lainnya', 'Pengeluaran', '2026-05-09', '2026-05-08', '2026-05-08 19:02:45', '2026-05-09 04:02:45'),
(114, 'moy5yv7s-2wdb9w6', 24, NULL, 1, 'Patungin', 150000.00, 'BANK MANDIRI', NULL, 'Lainnya', 'Pengeluaran', '2026-05-09', '2026-05-09', '2026-05-09 04:02:45', '2026-05-09 04:02:45');

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

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

CREATE TABLE `users` (
  `user_id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `full_name` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `telegram_chat_id` varchar(50) NOT NULL,
  `uniq_id` varchar(50) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `users` (`user_id`, `username`, `full_name`, `password`, `telegram_chat_id`, `uniq_id`, `created_at`) VALUES
(24, '6310843350', 'Kelvin Ilyas', 'rekapin123', '6310843350', 'USR-286C-3385', '2026-04-27 03:52:18'),
(25, '6495353594', 'Meirizka ', 'rekapin123', '6495353594', 'USR-2478-6782', '2026-04-27 04:31:38');

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

--
-- Table structure for table `wallets`
--

CREATE TABLE `wallets` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `icon` varchar(50) DEFAULT 'wallet',
  `color` varchar(20) DEFAULT '#3B82F6',
  `balance` decimal(15,2) DEFAULT 0.00,
  `type` enum('cash','bank','ewallet','investment','savings') DEFAULT 'cash',
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `wallets`
--

INSERT INTO `wallets` (`id`, `user_id`, `name`, `icon`, `color`, `balance`, `type`, `created_at`) VALUES
(1, 24, 'BCA', 'wallet', '#3b82f6', 0.00, 'bank', '2026-04-27 04:32:27'),
(2, 24, 'Seabank', 'wallet', '#3b82f6', 0.00, 'bank', '2026-05-06 16:57:08'),
(3, 24, 'GoPay', 'wallet', '#3b82f6', 0.00, 'ewallet', '2026-05-07 17:44:12');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `budgets`
--
ALTER TABLE `budgets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_budget` (`user_id`,`category`,`period`);

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_cat` (`user_id`,`name`,`type`),
  ADD KEY `idx_categories_user` (`user_id`,`type`);

--
-- Indexes for table `collaborators`
--
ALTER TABLE `collaborators`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_collab` (`owner_user_id`,`collaborator_chat_id`);

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

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

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

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

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

--
-- Indexes for table `transactions`
--
ALTER TABLE `transactions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_user_date` (`user_id`,`receipt_date`),
  ADD KEY `idx_type` (`type`),
  ADD KEY `idx_transactions_user_date` (`user_id`,`receipt_date`),
  ADD KEY `idx_transactions_member` (`member_id`),
  ADD KEY `idx_transactions_wallet` (`wallet_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`user_id`),
  ADD UNIQUE KEY `idx_telegram_chat_id` (`telegram_chat_id`),
  ADD UNIQUE KEY `uniq_id` (`uniq_id`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `budgets`
--
ALTER TABLE `budgets`
  ADD CONSTRAINT `budgets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `categories`
--
ALTER TABLE `categories`
  ADD CONSTRAINT `categories_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `collaborators`
--
ALTER TABLE `collaborators`
  ADD CONSTRAINT `collaborators_ibfk_1` FOREIGN KEY (`owner_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `debts`
--
ALTER TABLE `debts`
  ADD CONSTRAINT `debts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `members`
--
ALTER TABLE `members`
  ADD CONSTRAINT `members_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `recurring_transactions`
--
ALTER TABLE `recurring_transactions`
  ADD CONSTRAINT `recurring_transactions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `savings_goals`
--
ALTER TABLE `savings_goals`
  ADD CONSTRAINT `savings_goals_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `transactions`
--
ALTER TABLE `transactions`
  ADD CONSTRAINT `fk_user_transaction` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE;

--
-- Constraints for table `wallets`
--
ALTER TABLE `wallets`
  ADD CONSTRAINT `wallets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_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 */;
