text: -- phpMyAdmin SQL Dump
  -- version 4.6.6deb5
  -- https://www.phpmyadmin.net/
  --
  -- Host: localhost:3306
  -- Generation Time: 23 Jan 2020 pada 03.20
  -- Versi Server: 5.7.28-0ubuntu0.18.04.4
  -- PHP Version: 7.2.24-0ubuntu0.18.04.2
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  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: `tikret`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `kelas`
  --
  
  CREATE TABLE `kelas` (
    `id` int(11) NOT NULL,
    `nama` varchar(20) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `kereta`
  --
  
  CREATE TABLE `kereta` (
    `id` int(11) NOT NULL,
    `nama` varchar(50) NOT NULL,
    `jml_kursi` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `kursi`
  --
  
  CREATE TABLE `kursi` (
    `id` int(11) NOT NULL,
    `kereta_id` int(11) NOT NULL,
    `kode_kursi` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `pembayaran`
  --
  
  CREATE TABLE `pembayaran` (
    `id` int(11) NOT NULL,
    `pesan_id` int(11) NOT NULL,
    `bukti_transfer` varchar(50) NOT NULL,
    `status_pembayaran` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `pesan`
  --
  
  CREATE TABLE `pesan` (
    `id` int(11) NOT NULL,
    `kode_tiket` varchar(50) NOT NULL,
    `jml_tiket` int(50) NOT NULL,
    `tiket_id` int(11) NOT NULL,
    `status_bayar` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `pesan_has_kursi`
  --
  
  CREATE TABLE `pesan_has_kursi` (
    `id` int(11) NOT NULL,
    `kursi_id` int(11) NOT NULL,
    `pesan_id` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `role`
  --
  
  CREATE TABLE `role` (
    `id` int(11) NOT NULL,
    `title` varchar(20) NOT NULL,
    `descripsi` varchar(50) NOT NULL,
    `level` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `role`
  --
  
  INSERT INTO `role` (`id`, `title`, `descripsi`, `level`) VALUES
  (1, 'admin', 'user untuk admin', 1),
  (2, 'member', 'user untuk member', 2);
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `stasiun`
  --
  
  CREATE TABLE `stasiun` (
    `id` int(11) NOT NULL,
    `nama_stasiun` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `stasiun`
  --
  
  INSERT INTO `stasiun` (`id`, `nama_stasiun`) VALUES
  (2, 'meranggenn');
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `tiket`
  --
  
  CREATE TABLE `tiket` (
    `id` int(11) NOT NULL,
    `kereta_id` int(11) NOT NULL,
    `kelas_id` int(11) NOT NULL,
    `berangkat` varchar(50) NOT NULL,
    `tujuan` varchar(50) NOT NULL,
    `jam_berangkat` time NOT NULL,
    `jam_sampai` time NOT NULL,
    `stock` int(50) NOT NULL,
    `harga_tiket` int(50) NOT NULL,
    `tanggal` date NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `user`
  --
  
  CREATE TABLE `user` (
    `id` int(11) NOT NULL,
    `username` varchar(50) NOT NULL,
    `email` varchar(50) NOT NULL,
    `password` varchar(255) NOT NULL,
    `active` int(11) NOT NULL,
    `token` varchar(7) NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `user`
  --
  
  INSERT INTO `user` (`id`, `username`, `email`, `password`, `active`, `token`, `created_at`, `updated_at`) VALUES
  (1, 'Bagus', 'bagusfikrianto7@gmail.com', '$2y$10$vI5TgoVzKHGoTxZakn36eu6SQB0UTmz.QsLjetmexZsJPwGa3W.XC', 1, 's9lLu', '2020-01-21 00:07:49', NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `user_has_role`
  --
  
  CREATE TABLE `user_has_role` (
    `id` int(11) NOT NULL,
    `user_id` int(11) NOT NULL,
    `role_id` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `user_has_role`
  --
  
  INSERT INTO `user_has_role` (`id`, `user_id`, `role_id`) VALUES
  (1, 1, 1);
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `kelas`
  --
  ALTER TABLE `kelas`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `kereta`
  --
  ALTER TABLE `kereta`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `kursi`
  --
  ALTER TABLE `kursi`
    ADD PRIMARY KEY (`id`),
    ADD KEY `kereta_id` (`kereta_id`);
  
  --
  -- Indexes for table `pembayaran`
  --
  ALTER TABLE `pembayaran`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `pesan`
  --
  ALTER TABLE `pesan`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `pesan_has_kursi`
  --
  ALTER TABLE `pesan_has_kursi`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `role`
  --
  ALTER TABLE `role`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `stasiun`
  --
  ALTER TABLE `stasiun`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `tiket`
  --
  ALTER TABLE `tiket`
    ADD PRIMARY KEY (`id`),
    ADD KEY `kereta_id` (`kereta_id`),
    ADD KEY `kelas_id` (`kelas_id`);
  
  --
  -- Indexes for table `user`
  --
  ALTER TABLE `user`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `user_has_role`
  --
  ALTER TABLE `user_has_role`
    ADD PRIMARY KEY (`id`),
    ADD KEY `user_id` (`user_id`),
    ADD KEY `role_id` (`role_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `kelas`
  --
  ALTER TABLE `kelas`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  --
  -- AUTO_INCREMENT for table `kereta`
  --
  ALTER TABLE `kereta`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  --
  -- AUTO_INCREMENT for table `kursi`
  --
  ALTER TABLE `kursi`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
  --
  -- AUTO_INCREMENT for table `pembayaran`
  --
  ALTER TABLE `pembayaran`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `pesan`
  --
  ALTER TABLE `pesan`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `pesan_has_kursi`
  --
  ALTER TABLE `pesan_has_kursi`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `role`
  --
  ALTER TABLE `role`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `stasiun`
  --
  ALTER TABLE `stasiun`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `tiket`
  --
  ALTER TABLE `tiket`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `user`
  --
  ALTER TABLE `user`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  --
  -- AUTO_INCREMENT for table `user_has_role`
  --
  ALTER TABLE `user_has_role`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  --
  -- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
  --
  
  --
  -- Ketidakleluasaan untuk tabel `kursi`
  --
  ALTER TABLE `kursi`
    ADD CONSTRAINT `kursi_ibfk_1` FOREIGN KEY (`kereta_id`) REFERENCES `kereta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Ketidakleluasaan untuk tabel `tiket`
  --
  ALTER TABLE `tiket`
    ADD CONSTRAINT `tiket_ibfk_1` FOREIGN KEY (`kereta_id`) REFERENCES `kereta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `tiket_ibfk_2` FOREIGN KEY (`kelas_id`) REFERENCES `kelas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Ketidakleluasaan untuk tabel `user_has_role`
  --
  ALTER TABLE `user_has_role`
    ADD CONSTRAINT `user_has_role_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `user_has_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  /*!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 */;
  