Skip to content

Instantly share code, notes, and snippets.

@milan-sahana
Created April 21, 2024 06:06
Show Gist options
  • Save milan-sahana/789b560f079a54ea86f3570c62be0e8b to your computer and use it in GitHub Desktop.
Save milan-sahana/789b560f079a54ea86f3570c62be0e8b to your computer and use it in GitHub Desktop.
Unique Email id by GENERATED index
-- phpMyAdmin SQL Dump
-- version 5.1.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Apr 21, 2024 at 06:00 AM
-- Server version: 10.6.16-MariaDB-0ubuntu0.22.04.1
-- PHP Version: 7.4.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 */;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`user_login` varchar(60) NOT NULL DEFAULT '',
`user_pass` varchar(255) NOT NULL DEFAULT '',
`user_role` enum('','admin','user','guest','event_manager') NOT NULL,
`user_nicename` varchar(50) NOT NULL DEFAULT '' COMMENT 'Full Name',
`user_mobile` varchar(12) DEFAULT NULL,
`user_email` varchar(100) NOT NULL DEFAULT '',
`user_url` varchar(100) NOT NULL DEFAULT '',
`user_registered` timestamp NOT NULL DEFAULT current_timestamp(),
`user_activation_key` varchar(255) DEFAULT '',
`user_status` int(11) NOT NULL DEFAULT 0 COMMENT '0- Active, 1- Blocked/Disabled, 2-Suspended',
`profile_pic` varchar(254) NOT NULL DEFAULT '',
`updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`google_oauth_id` varchar(150) DEFAULT NULL COMMENT 'google_user Oauth2 id',
`email_normal` varchar(255) GENERATED ALWAYS AS (concat_ws('@',substring_index(substring_index(`user_email`,'@',1),'+',1),substring_index(`user_email`,'@',-1))) VIRTUAL,
`user_gender` varchar(25) DEFAULT NULL COMMENT 'Male, Female',
`user_dob` date DEFAULT NULL COMMENT 'date of Birth'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `user_email` (`user_email`),
ADD UNIQUE KEY `google_oauth_id` (`google_oauth_id`),
ADD UNIQUE KEY `email_normal` (`email_normal`),
ADD KEY `user_login_key` (`user_login`),
ADD KEY `user_nicename` (`user_nicename`),
ADD KEY `user_mobile` (`user_mobile`) USING BTREE;
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=205;
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 */;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment