Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 5, 2020 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4ebd36a9b5c44481d0f539aba9f2ea09 to your computer and use it in GitHub Desktop.
Save parzibyte/4ebd36a9b5c44481d0f539aba9f2ea09 to your computer and use it in GitHub Desktop.
CREATE TABLE IF NOT EXISTS users(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS links(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
hash varchar(6) UNIQUE,
title varchar(255) NOT NULL,
real_link varchar(1024) NOT NULL,
instant_redirect BOOLEAN DEFAULT 1
);
CREATE TABLE IF NOT EXISTS statistics(
link_id BIGINT UNSIGNED NOT NULL,
date varchar(10) NOT NULL,
FOREIGN KEY (link_id) REFERENCES links(id) ON DELETE CASCADE ON UPDATE CASCADE
);
# A default user. Password is 'hunter2'
INSERT INTO `users` (`email`, `password`) VALUES
('parzibyte@gmail.com', '$2y$10$DVMlG/zp8rB3KrW6oRvpvOgbIkoRRfOXu/9H5DgTfVQXwZP5m.tQy');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment