CREATE DATABASE IF NOT EXISTS `05_povertydb` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `05_povertydb`;
SET FOREIGN_KEY_CHECKS=0;
-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Jun 12, 2026 at 10:30 AM
-- Server version: 8.4.3
-- PHP Version: 8.3.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: `05_povertydb`
--

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

--
-- Table structure for table `penerima_bantuan`
--

CREATE TABLE `penerima_bantuan` (
  `id` int NOT NULL,
  `user_id` int DEFAULT NULL,
  `rumah_ibadah_id` int DEFAULT NULL,
  `nama_penerima` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nik` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `no_hp` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `alamat` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `pekerjaan` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `penghasilan` int NOT NULL,
  `jumlah_tanggungan` int NOT NULL,
  `kondisi_rumah` enum('baik','sedang','rusak') COLLATE utf8mb4_unicode_ci NOT NULL,
  `jenis_bantuan` enum('zakat','sembako','uang_tunai','lainnya') COLLATE utf8mb4_unicode_ci NOT NULL,
  `latitude` double NOT NULL,
  `longitude` double NOT NULL,
  `jarak_meter` double DEFAULT NULL,
  `status_pengajuan` enum('menunggu','diterima','ditolak','dibatalkan') COLLATE utf8mb4_unicode_ci DEFAULT 'menunggu',
  `status_hapus` enum('normal','menunggu','disetujui','ditolak') COLLATE utf8mb4_unicode_ci DEFAULT 'normal',
  `alasan_hapus` text COLLATE utf8mb4_unicode_ci,
  `alasan_status` text COLLATE utf8mb4_unicode_ci,
  `sumber_pengajuan` enum('mandiri','admin_rumah_ibadah') COLLATE utf8mb4_unicode_ci NOT NULL,
  `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_unicode_ci;

--
-- Dumping data for table `penerima_bantuan`
--

INSERT INTO `penerima_bantuan` (`id`, `user_id`, `rumah_ibadah_id`, `nama_penerima`, `nik`, `no_hp`, `alamat`, `pekerjaan`, `penghasilan`, `jumlah_tanggungan`, `kondisi_rumah`, `jenis_bantuan`, `latitude`, `longitude`, `jarak_meter`, `status_pengajuan`, `status_hapus`, `alasan_hapus`, `alasan_status`, `sumber_pengajuan`, `created_at`, `updated_at`) VALUES
(1, 4, 1, 'Jotok', '60103011704940005', '08567891325', 'Jl. Bujang Malaka, RT/RW 024/008, Beringin, Kapuas, Sanggau', 'Tukang Antar Koran', 500000, 2, 'sedang', 'sembako', -0.07088082929060342, 109.[REDACTED], 160.17, 'diterima', 'normal', NULL, '', 'mandiri', '2026-06-09 10:10:05', '2026-06-09 11:56:27'),
(2, 6, 5, 'caca', '124854', '410154', 'Gg. Kasturi Raja, Jl. Kenari', 'Mahasiswa', 0, 0, 'baik', 'uang_tunai', -0.020854501391015294, 109.33250427246095, 259.51, 'diterima', 'normal', NULL, '', 'mandiri', '2026-06-09 10:57:26', '2026-06-09 14:53:12'),
(4, NULL, 2, 'angel1', '123456', '123456', '1234', 'wwwwww', 0, 0, 'sedang', 'uang_tunai', -0.025105475576032914, 109.33623790740968, 128.27, 'diterima', 'normal', NULL, '', 'admin_rumah_ibadah', '2026-06-09 11:27:12', '2026-06-09 11:28:31'),
(5, NULL, 2, 'angel2', '123', '123', 'ssss', 'sssss', 0, 0, 'sedang', 'uang_tunai', -0.025245714451433383, 109.33630228042604, 122.41, 'diterima', 'normal', NULL, '', 'admin_rumah_ibadah', '2026-06-09 11:28:22', '2026-06-09 11:28:29'),
(6, 4, 1, 'k', 'g', 'u', 'k', 'i', 5, 7, 'baik', 'zakat', -0.06864918884517689, 109.3591332435608, 218.94, 'dibatalkan', 'disetujui', 'h', 'h', 'admin_rumah_ibadah', '2026-06-09 11:57:59', '2026-06-09 12:19:58'),
(7, 9, 5, 'penerima03', '124854', '123', 'Gang Merak II, Mariana, Pontianak Kota, Pontianak, Kalimantan Barat, Kalimantan, 78112, Indonesia', 'Mahasiswa', 50000, 1, 'sedang', 'sembako', -0.02033240043514327, 109.33441936969759, 136.81, 'diterima', 'normal', NULL, '', 'admin_rumah_ibadah', '2026-06-09 14:52:40', '2026-06-09 14:53:12'),
(8, 10, 1, 'penerima04', '222223432', '13334341', 'Komplek Mitra Indah Utama I, Bangka Belitung Darat, Pontianak Tenggara, Pontianak, Kalimantan Barat, Kalimantan, 78124, Indonesia', 'wiraswasta', 1000000, 3, 'baik', 'sembako', -0.06962094072669782, 109.35720741748811, 299.36, 'diterima', 'normal', NULL, '', 'admin_rumah_ibadah', '2026-06-10 01:22:26', '2026-06-10 01:22:34'),
(9, 11, 1, 'penerima05', '111111111111111', '11111111111111111', 'Nilam Permai, Sungai Raya, Kubu Raya, Kalimantan Barat, Kalimantan, 78124, Indonesia', 'disabilitas', 0, 1, 'rusak', 'uang_tunai', -0.07270815709759908, 109.3613098561764, 299.07, 'diterima', 'normal', NULL, '', 'admin_rumah_ibadah', '2026-06-10 01:25:25', '2026-06-10 01:25:37');

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

--
-- Table structure for table `penyaluran_bantuan`
--

CREATE TABLE `penyaluran_bantuan` (
  `id` int NOT NULL,
  `program_id` int DEFAULT NULL,
  `penerima_id` int NOT NULL,
  `rumah_ibadah_id` int NOT NULL,
  `admin_id` int NOT NULL,
  `jenis_bantuan` enum('zakat','sembako','uang_tunai','lainnya') COLLATE utf8mb4_unicode_ci NOT NULL,
  `nominal` int DEFAULT NULL,
  `jumlah_item` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bantuan_ke` int DEFAULT NULL,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `tanggal_penyaluran` date NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `penyaluran_bantuan`
--

INSERT INTO `penyaluran_bantuan` (`id`, `program_id`, `penerima_id`, `rumah_ibadah_id`, `admin_id`, `jenis_bantuan`, `nominal`, `jumlah_item`, `bantuan_ke`, `keterangan`, `tanggal_penyaluran`, `created_at`) VALUES
(1, 5, 5, 2, 5, 'zakat', 10000, NULL, 1, 'gg', '2026-06-09', '2026-06-09 11:33:36');

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

--
-- Table structure for table `program_bantuan`
--

CREATE TABLE `program_bantuan` (
  `id` int NOT NULL,
  `rumah_ibadah_id` int DEFAULT NULL,
  `nama_program` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `jenis_bantuan` enum('zakat','sembako','uang_tunai','lainnya') COLLATE utf8mb4_unicode_ci NOT NULL,
  `deskripsi` text COLLATE utf8mb4_unicode_ci,
  `bulan` int NOT NULL,
  `tahun` int NOT NULL,
  `target_frekuensi` int DEFAULT '1',
  `nominal` int DEFAULT NULL,
  `jumlah_item` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status_program` enum('aktif','selesai','dibatalkan') COLLATE utf8mb4_unicode_ci DEFAULT 'aktif',
  `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_unicode_ci;

--
-- Dumping data for table `program_bantuan`
--

INSERT INTO `program_bantuan` (`id`, `rumah_ibadah_id`, `nama_program`, `jenis_bantuan`, `deskripsi`, `bulan`, `tahun`, `target_frekuensi`, `nominal`, `jumlah_item`, `status_program`, `created_at`, `updated_at`) VALUES
(3, 2, 'a', 'uang_tunai', 'a', 6, 2026, 1, NULL, NULL, 'aktif', '2026-06-09 11:29:28', '2026-06-09 11:29:28'),
(4, 2, 'b', 'uang_tunai', 'b', 6, 2026, 1, NULL, NULL, 'aktif', '2026-06-09 11:29:47', '2026-06-09 11:29:47'),
(5, 2, 'c', 'sembako', 'c', 6, 2026, 1, NULL, NULL, 'aktif', '2026-06-09 11:30:54', '2026-06-09 11:30:54');

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

--
-- Table structure for table `riwayat_status`
--

CREATE TABLE `riwayat_status` (
  `id` int NOT NULL,
  `penerima_id` int NOT NULL,
  `user_id` int NOT NULL,
  `status_lama` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status_baru` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `catatan` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `riwayat_status`
--

INSERT INTO `riwayat_status` (`id`, `penerima_id`, `user_id`, `status_lama`, `status_baru`, `catatan`, `created_at`) VALUES
(1, 1, 4, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 10:10:05'),
(2, 1, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 10:48:16'),
(3, 2, 6, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 10:57:26'),
(4, 2, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 10:59:04'),
(7, 4, 5, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 11:27:12'),
(8, 5, 1, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 11:28:22'),
(9, 5, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 11:28:29'),
(10, 4, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 11:28:31'),
(11, 6, 1, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 11:57:59'),
(12, 6, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 11:58:09'),
(13, 6, 1, 'diterima', 'dibatalkan', 'jotok 2 rmh', '2026-06-09 11:58:22'),
(14, 6, 1, 'dibatalkan', 'hapus_disetujui', 'h', '2026-06-09 12:19:58'),
(15, 7, 1, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-09 14:52:40'),
(16, 7, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-09 14:52:49'),
(17, 8, 1, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-10 01:22:26'),
(18, 8, 1, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-10 01:22:34'),
(19, 9, 2, NULL, 'menunggu', 'Pengajuan penerima dibuat.', '2026-06-10 01:25:25'),
(20, 9, 2, 'menunggu', 'diterima', 'Status penerima diubah.', '2026-06-10 01:25:37');

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

--
-- Table structure for table `rumah_ibadah`
--

CREATE TABLE `rumah_ibadah` (
  `id` int NOT NULL,
  `user_id` int DEFAULT NULL,
  `nama_rumah_ibadah` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `agama` enum('islam','kristen','katolik','hindu','buddha','konghucu') COLLATE utf8mb4_unicode_ci NOT NULL,
  `alamat` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `nomor_hp` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `latitude` double NOT NULL,
  `longitude` double NOT NULL,
  `status_pengajuan` enum('menunggu','diterima','ditolak') COLLATE utf8mb4_unicode_ci DEFAULT 'menunggu',
  `status_hapus` enum('normal','menunggu','disetujui','ditolak') COLLATE utf8mb4_unicode_ci DEFAULT 'normal',
  `alasan_hapus` text COLLATE utf8mb4_unicode_ci,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `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_unicode_ci;

--
-- Dumping data for table `rumah_ibadah`
--

INSERT INTO `rumah_ibadah` (`id`, `user_id`, `nama_rumah_ibadah`, `agama`, `alamat`, `nomor_hp`, `latitude`, `longitude`, `status_pengajuan`, `status_hapus`, `alasan_hapus`, `keterangan`, `created_at`, `updated_at`) VALUES
(1, 2, 'Gereja Katolik Paroki St. Sesilia', 'katolik', 'Jl. Sungai Raya Dalam', '0812345678913', -0.07052077848657445, 109.3597447872162, 'diterima', 'normal', NULL, '', '2026-06-09 10:11:48', '2026-06-09 10:48:18'),
(2, 5, 'GPIB', 'kristen', 'Jl. Kartini, Pontianak', '0812345678913', -0.02508443513561694, 109.33739125728609, 'diterima', 'normal', NULL, '', '2026-06-09 10:54:13', '2026-06-09 10:59:11'),
(4, 8, 'Gereja Elim', 'kristen', 'Jalan Rajawali, Tengah, Pontianak Kota, Pontianak, Kalimantan Barat, Kalimantan, 78112, Indonesia', '0812345678913', -0.02152069970142388, 109.33472514152527, 'ditolak', 'disetujui', 's', 's', '2026-06-09 14:50:50', '2026-06-09 14:51:16'),
(5, 8, 'Gereja Elim', 'kristen', 'Jalan Rajawali, Tengah, Pontianak Kota, Pontianak, Kalimantan Barat, Kalimantan, 78112, Indonesia', '0812345678913', -0.02151988492191236, 109.33474123477937, 'diterima', 'normal', NULL, 'Ditambahkan langsung oleh super admin.', '2026-06-09 14:53:12', '2026-06-09 14:53:12');

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

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

CREATE TABLE `users` (
  `id` int NOT NULL,
  `nama` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('super_admin','admin_rumah_ibadah','penerima') COLLATE utf8mb4_unicode_ci NOT NULL,
  `status_akun` enum('aktif','nonaktif') COLLATE utf8mb4_unicode_ci DEFAULT 'aktif',
  `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_unicode_ci;

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

INSERT INTO `users` (`id`, `nama`, `username`, `password`, `role`, `status_akun`, `created_at`, `updated_at`) VALUES
(1, 'Super Admin Dinas Sosial', 'superadmin', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'super_admin', 'aktif', '2026-06-09 10:04:24', '2026-06-09 14:48:23'),
(2, 'admingerejasesilia', 'admingerejasesilia', '$2y$10$Pt4VTj7yDLt1xabM5WwGJuBo.gat807fkV0Q.KiGKv.V0tRbo1SHW', 'admin_rumah_ibadah', 'aktif', '2026-06-09 10:06:38', '2026-06-10 01:23:46'),
(4, 'penerima01', 'penerima01', '$2y$12$79Vc.m66x5uIIIt4rifL0OIY3qrzzXmgktTW3Y1QEwWB9GMaeLFni', 'penerima', 'nonaktif', '2026-06-09 10:08:28', '2026-06-10 01:18:35'),
(5, 'admingpib', 'admingpib', '$2y$12$79Vc.m66x5uIIIt4rifL0OIY3qrzzXmgktTW3Y1QEwWB9GMaeLFni', 'admin_rumah_ibadah', 'nonaktif', '2026-06-09 10:52:35', '2026-06-09 14:47:58'),
(6, 'penerima02', 'penerima02', '$2y$12$79Vc.m66x5uIIIt4rifL0OIY3qrzzXmgktTW3Y1QEwWB9GMaeLFni', 'penerima', 'aktif', '2026-06-09 10:55:15', '2026-06-09 14:47:48'),
(8, 'Admin Gereja Elim', 'admingerejaelim', '$2y$10$hiPcHEFAb2lPq3WKLra1MuZ8220s/UY.3PG24ZIrmbxrbp2imboGO', 'admin_rumah_ibadah', 'aktif', '2026-06-09 14:49:55', '2026-06-09 14:49:55'),
(9, 'penerima03', 'penerima03', '$2y$10$.50kERk9OSPvJhe.9IFxd.3qi2j5spTxtM36Kx1mI7Q3HkeVlyzvm', 'penerima', 'nonaktif', '2026-06-09 14:51:50', '2026-06-10 01:18:20'),
(10, 'penerima04', 'penerima04', '$2y$10$Q0yfgX7/KnCa4sxnz/f5YupK2aVyKWLDPO8CD/mdQlCSOTRbzLBli', 'penerima', 'aktif', '2026-06-10 01:20:04', '2026-06-10 01:20:04'),
(11, 'penerima05', 'penerima05', '$2y$10$0UJ97IYsDsS/K/qJbHJsiO938TFSU2AorU0fqxAawnbpwhJN/qBqi', 'penerima', 'aktif', '2026-06-10 01:21:01', '2026-06-10 01:21:01');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `penerima_bantuan`
--
ALTER TABLE `penerima_bantuan`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_pb_user` (`user_id`),
  ADD KEY `idx_pb_ri` (`rumah_ibadah_id`),
  ADD KEY `idx_pb_status` (`status_pengajuan`),
  ADD KEY `idx_pb_jenis` (`jenis_bantuan`);

--
-- Indexes for table `penyaluran_bantuan`
--
ALTER TABLE `penyaluran_bantuan`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_pen_program` (`program_id`),
  ADD KEY `idx_pen_penerima` (`penerima_id`),
  ADD KEY `idx_pen_ri` (`rumah_ibadah_id`),
  ADD KEY `idx_pen_admin` (`admin_id`),
  ADD KEY `idx_pen_tanggal` (`tanggal_penyaluran`);

--
-- Indexes for table `program_bantuan`
--
ALTER TABLE `program_bantuan`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_prog_ri` (`rumah_ibadah_id`),
  ADD KEY `idx_prog_periode` (`bulan`,`tahun`),
  ADD KEY `idx_prog_status` (`status_program`);

--
-- Indexes for table `riwayat_status`
--
ALTER TABLE `riwayat_status`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_rw_penerima` (`penerima_id`),
  ADD KEY `idx_rw_user` (`user_id`);

--
-- Indexes for table `rumah_ibadah`
--
ALTER TABLE `rumah_ibadah`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ri_user` (`user_id`),
  ADD KEY `idx_ri_status` (`status_pengajuan`),
  ADD KEY `idx_ri_agama` (`agama`);

--
-- 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 `penerima_bantuan`
--
ALTER TABLE `penerima_bantuan`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `penyaluran_bantuan`
--
ALTER TABLE `penyaluran_bantuan`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `program_bantuan`
--
ALTER TABLE `program_bantuan`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `riwayat_status`
--
ALTER TABLE `riwayat_status`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- AUTO_INCREMENT for table `rumah_ibadah`
--
ALTER TABLE `rumah_ibadah`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `penerima_bantuan`
--
ALTER TABLE `penerima_bantuan`
  ADD CONSTRAINT `fk_pb_ri` FOREIGN KEY (`rumah_ibadah_id`) REFERENCES `rumah_ibadah` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_pb_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `penyaluran_bantuan`
--
ALTER TABLE `penyaluran_bantuan`
  ADD CONSTRAINT `fk_pen_admin` FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_pen_penerima` FOREIGN KEY (`penerima_id`) REFERENCES `penerima_bantuan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_pen_program` FOREIGN KEY (`program_id`) REFERENCES `program_bantuan` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_pen_ri` FOREIGN KEY (`rumah_ibadah_id`) REFERENCES `rumah_ibadah` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `program_bantuan`
--
ALTER TABLE `program_bantuan`
  ADD CONSTRAINT `fk_prog_ri` FOREIGN KEY (`rumah_ibadah_id`) REFERENCES `rumah_ibadah` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `riwayat_status`
--
ALTER TABLE `riwayat_status`
  ADD CONSTRAINT `fk_rw_penerima` FOREIGN KEY (`penerima_id`) REFERENCES `penerima_bantuan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_rw_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rumah_ibadah`
--
ALTER TABLE `rumah_ibadah`
  ADD CONSTRAINT `fk_ri_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL 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 */;

SET FOREIGN_KEY_CHECKS=1;
