text: -- phpMyAdmin SQL Dump
  -- version 4.9.0.1
  -- https://www.phpmyadmin.net/
  --
  -- Host: localhost
  -- Generation Time: Jul 27, 2019 at 09:44 AM
  -- Server version: 10.4.6-MariaDB
  -- PHP Version: 7.3.7
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET AUTOCOMMIT = 0;
  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: `jf_webhook`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `fields`
  --
  
  CREATE TABLE `fields` (
    `id` int(11) NOT NULL,
    `token_id` int(11) NOT NULL,
    `col` int(11) NOT NULL,
    `form_field` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `forms`
  --
  
  CREATE TABLE `forms` (
    `id` int(11) NOT NULL,
    `form_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `hooks`
  --
  
  CREATE TABLE `hooks` (
    `id` int(11) NOT NULL,
    `token` int(11) NOT NULL,
    `spreadsheet_id` int(64) NOT NULL,
    `sheet` int(11) NOT NULL DEFAULT 0
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `spreadsheets`
  --
  
  CREATE TABLE `spreadsheets` (
    `id` int(11) NOT NULL,
    `spreadsheet_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tokens`
  --
  
  CREATE TABLE `tokens` (
    `id` int(11) NOT NULL,
    `token` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
    `user_id` int(11) NOT NULL,
    `form_id` int(11) NOT NULL,
    `enabled` tinyint(1) DEFAULT 0
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `users`
  --
  
  CREATE TABLE `users` (
    `id` int(11) NOT NULL,
    `google_id` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
    `token` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
    `refresh_token` varchar(512) COLLATE utf8mb4_unicode_ci NOT NULL,
    `jf_token` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `fields`
  --
  ALTER TABLE `fields`
    ADD PRIMARY KEY (`id`),
    ADD KEY `token_id_fk` (`token_id`);
  
  --
  -- Indexes for table `forms`
  --
  ALTER TABLE `forms`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `form_id` (`form_id`);
  
  --
  -- Indexes for table `hooks`
  --
  ALTER TABLE `hooks`
    ADD PRIMARY KEY (`id`),
    ADD KEY `ss_fk` (`spreadsheet_id`),
    ADD KEY `token_fk` (`token`);
  
  --
  -- Indexes for table `spreadsheets`
  --
  ALTER TABLE `spreadsheets`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `spreadsheet_id` (`spreadsheet_id`);
  
  --
  -- Indexes for table `tokens`
  --
  ALTER TABLE `tokens`
    ADD PRIMARY KEY (`id`),
    ADD KEY `user_fk` (`user_id`),
    ADD KEY `form_fk` (`form_id`);
  
  --
  -- Indexes for table `users`
  --
  ALTER TABLE `users`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `google_id` (`google_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `fields`
  --
  ALTER TABLE `fields`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `forms`
  --
  ALTER TABLE `forms`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `hooks`
  --
  ALTER TABLE `hooks`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `spreadsheets`
  --
  ALTER TABLE `spreadsheets`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `tokens`
  --
  ALTER TABLE `tokens`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT for table `users`
  --
  ALTER TABLE `users`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `fields`
  --
  ALTER TABLE `fields`
    ADD CONSTRAINT `token_id_fk` FOREIGN KEY (`token_id`) REFERENCES `tokens` (`id`);
  
  --
  -- Constraints for table `hooks`
  --
  ALTER TABLE `hooks`
    ADD CONSTRAINT `ss_fk` FOREIGN KEY (`spreadsheet_id`) REFERENCES `spreadsheets` (`id`),
    ADD CONSTRAINT `token_fk` FOREIGN KEY (`token`) REFERENCES `tokens` (`id`);
  
  --
  -- Constraints for table `tokens`
  --
  ALTER TABLE `tokens`
    ADD CONSTRAINT `form_fk` FOREIGN KEY (`form_id`) REFERENCES `forms` (`id`),
    ADD CONSTRAINT `user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
  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 */;
  