Verified Commit 601d109b authored by Javinator9889's avatar Javinator9889 🎼

Updated database files and removed unnecessary ones

parent 7b700309
Pipeline #94 canceled with stage
in 50 seconds
<mxfile host="Electron" modified="2019-10-19T12:28:34.301Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.1.0 Chrome/76.0.3809.139 Electron/6.0.7 Safari/537.36" etag="RDi0CIAmv17SyUSOKwRA" version="12.1.0" type="device" pages="1"><diagram name="Page-1" id="efa7a0a1-bf9b-a30e-e6df-94a7791c09e9">7V1Nl5s2FP01XjaHb5vlfGSaTdq0c3qarObIINt0AE1AZMb59RVGwraEOwyWkZgqmxjBCNC9enq670nM3Jvs5dcCPG0+oximM8eKX2bu7cxxbNddkP/qkm1TsrCcpmBdJDG9aF9wn/yEtNCipVUSw/LoQoxQipOn48II5TmM8FEZKAr0fHzZCqXHd30CaygU3EcgFUv/TmK8oW/hBPvyTzBZb9id7SBszixB9LguUJXT+80cd7X715zOAKuLvmi5ATF6PihyP87cmwIh3PzKXm5gWrcta7bm7+5OnG2fu4A57vMHle/e383/zLIAeD+j4J8s+eP3X2yXPt0PkFa0Rf4qYUEfGW9ZM+1eFNZV2TP3+nmTYHj/BKL67DMhBinb4Cylp9tX3R3gAj3CG5SiYleVa1muGwTkzCpJ04PyW++jfefX5SjHXdeDNFnnpCwib0we0b1ep6Cs4bfI7whlSUR/1xXc02evHyEFS5het3ixunOUw/YsKmJYcGd29TSMtT1yTJsKFhi+nETBbrElfQaiDOJiSy6hf+Ay3tPuYof0+HlPPptRZnNAvICWAcr3dVv1HnPyg8L+JgrYAgVmTpCS+15X5Me6/kFqoEXkHm2pwBJyO9Jv4esMOabTEV9OgfrfIA5j2SG4vVkngQU8CXpyYHE5DjgdHODBzeOr2uDuG/0A0L6t2dQKY8Eoc01H7oyqIoJ9bBcGxRri1ykuwnHQ4H5He7OyAqYAJz+OH7kLBHqHLyghL3MKbaErN29K/+jQgnP1BFw9NldP0w5CPT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" modified="2019-10-19T12:30:48.266Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.1.0 Chrome/76.0.3809.139 Electron/6.0.7 Safari/537.36" etag="v1HPNPNhdJK3ik61crrq" version="12.1.0" type="device" pages="1"><diagram name="Page-1" id="efa7a0a1-bf9b-a30e-e6df-94a7791c09e9">7V1Nl5s2FP01XjaHb5vlfGSaTdq0c3qarObIINt0AE1AZMb59RVGwraEOwyWkZgqmxjBCNC9enq670nM3Jvs5dcCPG0+oximM8eKX2bu7cxxbNddkP/qkm1TsrCcpmBdJDG9aF9wn/yEtNCipVUSw/LoQoxQipOn48II5TmM8FEZKAr0fHzZCqXHd30CaygU3EcgFUv/TmK8oW/hBPvyTzBZb9id7SBszixB9LguUJXT+80cd7X715zOAKuLvmi5ATF6PihyP87cmwIh3PzKXm5gWrcta7bm7+5OnG2fu4A57vMHle/e383/zLIAeD+j4J8s+eP3X2yXPt0PkFa0Rf4qYUEfGW9ZM+1eFNZV2TP3+nmTYHj/BKL67DMhBinb4Cylp9tX3R3gAj3CG5SiYleVa1muGwTkzCpJ04PyW++jfefX5SjHXdeDNFnnpCwib0we0b1ep6Cs4bfI7whlSUR/1xXc02evHyEFS5het3ixunOUw/YsKmJYcGd29TSMtT1yTJsKFhi+nETBbrElfQaiDOJiSy6hf+Ay3tPuYof0+HlPPptRZnNAvICWAcr3dVv1HnPyg8L+JgrYAgVmTpCS+15X5Me6/kFqoEXkHm2pwBJyO9Jv4esMOabTEV9OgfrfIA5j2SG4vVkngQU8CXpyYHE5DjgdHODBzeOr2uDuG/0A0L6t2dQKY8Eoc01H7oyqIoJ9bBcGxRri1ykuwnHQ4H5He7OyAqYAJz+OH7kLBHqHLyghL3MKbaErN29K/+jQgnP1BFw9NldP0w5CPTtGtC99DklcgSQ5yKCxAkOtQKCdGfAEhDFYG4BlDfbqAfYFgFOQG4SHIuwFvm4IBwLCq6Qo8QOIIkjwMEgPQzpwtOvL8/f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xWuLegzoAPcUlmfPe63YbIVgTOT2UtN/PYuz9fhj9pkWS3tFbQxIpJOnaFEp7kgSGJKOSRNTxJkAS35BkVJJ0Lf/UniS9VwIZkkghyRTTDtm0ypBkJJJMMu2wP0lClSQRZIuhS0/5TUn8cGyaTDHxkMW9dbclLrdCIRhqTFwuyiFslndxmkwy9bC3NWli7Mpowuce8guLe9OEj3ry4tnFaTLWFnqKaKI0Q9WdSxp0PD5ZbfRB53R+YpuHepfUqWomP1V6fmrYN93lcvmpjG8mP3XExZLHJFAfVA07khfNImgJUPPmXQesHQHrsm4dA7Esq25b6rMYQ1G8NNuW9QAz4MFcBCKW425cFk5RYmRu5euOfKjTUjPbGTrf4z/Jao893wvHEhn3W6bvd0n/RusYa8v0sPdKRtWqk8tZk/kwegkJl/yE8+L0mqI4ySY3r9NkoVTDtrldD21r6JJXx+NrGnvRazhFeZI5xdoThZ9PDNWdbG4SuhhbdwqnKE+yebL2NHk/Xo0oT5qNF2VtvOhagiDZMdsZdevFdqtPA/hFAOe8SNUbqzpWV7omv8d+CrbpbiW1CUGcu3Ebv6BHeQDCsUQ90gQgxmVBwL6kqkyvdKwJJlu2xutVd5CS3LiDZ7qDjtWlhXLDxT0G9b4bSWS+yCLBVHA7faqPWDuWKHTiJINicMMMB8Mw1iB+5VgTlBtbZvYYD5R+reUdjQcnPvhrLSHMdw31vYIlJn1bMPsm8nlsBLi01oXqDzY51gQVwtZB6WECdPpM65RNgFEILycYBVxgSr0+yIg7LavQd6cAOqU0VuFcq2BPcBl4f5oozmrgP9MZ8jHmvjTxeaeDnzWeoAmBDWwPLnuqLyhPPzD/VcEFtU971jU1SubgJDWt3hzUK8TZhjbONVV9vzj5Zg7ySsp5HCSHBUL48HLibmw+oxjWV/wL</diagram></mxfile>
\ No newline at end of file
#!/usr/bin/env python
#
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 by Aevum Softwares LTDA ME
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import optparse
import os
import re
__version__ = 0.1
SEQUENCE_SUFFIX = "sequence"
SCHEMA = "";
def remove_comments(string):
string = re.sub(re.compile("/\*.*?\*/", re.DOTALL), "", string) # remove all block comments (/*COMMENT */)
string = re.sub(re.compile("//.*?\n"), "", string) # remove all single line comments (//COMMENT\n)
return string
def remove_lines_started_with(word, lines):
toRemove = []
for line in lines:
if line.startswith(word):
toRemove.append(line)
for line in toRemove:
lines.remove(line)
def remove_lines_with(word, lines):
toRemove = []
for line in lines:
if word in line:
toRemove.append(line)
for line in toRemove:
lines.remove(line)
def remove_word(word, lines, numberOfNextWords=0):
substitute = "@@@"
for i in range(len(lines)):
if not numberOfNextWords:
lines[i] = lines[i].replace(word, "")
else:
line = lines[i]
line = line.replace(word, substitute)
if substitute in line:
split = line.split()
nextWords = []
for j in range(len(split)):
if split[j] == substitute:
for k in range(numberOfNextWords):
nextWords.append(split[k + j + 1])
replaceString = substitute
for k in range(numberOfNextWords):
replaceString = "{0} {1}".format(replaceString, nextWords[k])
lines[i] = line.replace(replaceString, "")
def put_semicolons(lines):
numberOfOpenningParenthesis = 0
numberOfClosingParenthesis = 0
for i in range(len(lines)):
line = lines[i]
split = lines[i].split()
if "CREATE" in split and "TABLE" in split:
if split.index("CREATE") == split.index("TABLE") - 1:
numberOfOpenningParenthesis = 0
numberOfClosingParenthesis = 0
while "(" in line:
line = line.replace("(", "", 1)
numberOfOpenningParenthesis = numberOfOpenningParenthesis + 1
while ")" in line:
line = line.replace(")", "", 1)
numberOfClosingParenthesis = numberOfClosingParenthesis + 1
if numberOfOpenningParenthesis == numberOfClosingParenthesis:
if numberOfOpenningParenthesis != 0:
lines[i] = lines[i].replace("\n", "") + ";\n"
numberOfOpenningParenthesis = 0
numberOfClosingParenthesis = 0
def create_sequences(lines):
sequences = []
lastTable = None
for i in range(len(lines)):
line = lines[i]
split = line.split()
if "CREATE" in split and "TABLE" in split:
if split.index("CREATE") == split.index("TABLE") - 1:
lastTable = split[split.index("CREATE") + 2]
elif "AUTO_INCREMENT" in line:
if "." in lastTable:
spl = lastTable.replace("\"", "").split(".")
schema = "\"" + spl[0] + "\"."
table = spl[1]
else:
table = lastTable.replace("\"", "")
schema = ""
column = split[0].replace("\"", "")
sequences.append({"table": table, "column": column, "schema": schema})
for sequence in sequences:
lines.append("{0} {1}\"{2}_{3}_{4}\";\n".format(
"DROP SEQUENCE IF EXISTS",
sequence["schema"],
sequence["table"],
sequence["column"],
SEQUENCE_SUFFIX))
lines.append("{0} {1}\"{2}_{3}_{4}\";\n".format(
"CREATE SEQUENCE ",
sequence["schema"],
sequence["table"],
sequence["column"],
SEQUENCE_SUFFIX))
lines.append("ALTER TABLE {0}\"{1}\" ALTER COLUMN \"{2}\" SET DEFAULT NEXTVAL('{0}\"{1}_{2}_{3}\"');\n".format(
sequence["schema"],
sequence["table"],
sequence["column"],
SEQUENCE_SUFFIX,))
def get_current_schema(lines):
for line in lines:
if "CREATE SCHEMA" in line:
return re.sub('\s+',' ',line.replace(';', '').replace('"', '')).strip().split(' ')[-1]
elif "CREATE TABLE" in line:
tbl = re.search("CREATE TABLE (.*) \(", line).group(1).replace('"', '')
if "." in tbl:
return tbl.split('.')[0].strip()
return None
def set_schema(lines):
currSchema = get_current_schema(lines)
if currSchema == None:
print("There is no schema set on the original script! Will default to public schema") # Not implemented: add schema to all statements
else:
for i in range(len(lines)):
line = lines[i]
regex = re.compile("((" + currSchema + ")(\")?(\.|;))")
search = regex.search(line)
if search:
sufix = ''
if search.group(3):
sufix += search.group(3);
if search.group(4):
sufix += search.group(4)
line = re.sub(regex, SCHEMA + sufix, line)
lines[i] = line
def replace_word(word, replace, lines):
for i in range(len(lines)):
lines[i] = lines[i].replace(word, replace)
def replace_regex(search, replace, lines):
for i in range(len(lines)):
lines[i] = re.sub(re.compile(search), replace, lines[i])
def add_cascade_to_drops(lines):
for i in range(len(lines)):
line = lines[i]
if line.startswith("DROP"):
lines[i] = line.replace(";", "CASCADE;")
def convert(input, output):
contents = input.read()
lines = remove_comments(contents).splitlines(True)
remove_lines_with("ASC)", lines)
remove_lines_started_with("SET", lines)
remove_lines_started_with("COLLATE", lines)
remove_lines_started_with("ENGINE", lines)
remove_lines_started_with("COMMENT", lines)
remove_lines_started_with("PACK_KEYS", lines)
replace_regex("COMMENT .*,\n", ",\n", lines)
remove_word(" COMMENT ", lines)
remove_lines_started_with("USE", lines)
replace_word("`", "\"", lines)
#remove_word("'", lines) # this breaks DEFAULT '' statements
remove_word("UNSIGNED", lines)
remove_word("IF NOT EXISTS", lines)
replace_regex("CREATE SCHEMA (.*);", r"CREATE SCHEMA IF NOT EXISTS \1;", lines)
remove_word("DEFAULT CHARACTER SET =", lines, 1)
remove_word("DEFAULT CHARACTER SET", lines, 1)
remove_word("CHARACTER SET", lines, 1)
remove_word("COLLATE", lines, 1)
replace_word("DATETIME", "TIMESTAMP", lines)
replace_word("TINYINT(1)", "BOOLEAN", lines)
replace_word("LONGTEXT", "TEXT", lines)
replace_regex("INT\(\d*\)", "INT", lines)
remove_word("CONSTRAINT \"\"", lines)
remove_word("FOREIGN KEY ()", lines)
put_semicolons(lines)
add_cascade_to_drops(lines)
create_sequences(lines)
remove_word("AUTO_INCREMENT", lines)
if SCHEMA != "":
set_schema(lines);
output.writelines(lines)
def main(args):
"""Check arguments from the command line and executed the required action"""
parser = optparse.OptionParser(
usage="Usage: %prog [options] <input_file> [<output_file>]",
version="%prog {0}".format(__version__))
parser.add_option("-s", "--schema",
action="store", dest="schema",
help="Schema name for the Postgre script. Default value is the table name for MySQL Workbench.");
# parser.add_option("-o", "--output",
# action="store", dest="output",
# help="Generates the output")
(options, args) = parser.parse_args()
if len(args) > 0:
input_path = args[0]
if not os.path.exists(input_path):
print("First argument should be a valid sql file")
return
if len(args) < 2:
output_path = "{0}_postgre.{1}".format(*input_path.rsplit('.', 1))
else:
output_path = args[1]
if options.schema != "" and options.schema != None:
global SCHEMA
SCHEMA = options.schema
input = open(input_path, "r")
output = open(output_path, "w")
convert(input, output)
else:
print ("Invalid parameters. You should run YYY <input> [<output>]")
return
if __name__ == "__main__":
main(sys.argv)
-- MySQL Script generated by MySQL Workbench
-- jue 25 jul 2019 13:50:06 CEST
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
-- SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
-- SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
-- SET @[email protected]@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema youtubemd
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema youtubemd
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `youtubemd` DEFAULT CHARACTER SET utf8mb4 ;
SHOW WARNINGS;
-- USE `youtubemd` ;
-- -----------------------------------------------------
-- Table `youtubemd`.`DownloadInformation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`DownloadInformation` (
`file_id` VARCHAR(50) NOT NULL,
`audioQuality` ENUM('320k', '256k', '128k') NOT NULL,
`audioSampling` ENUM('44000', '48000') NULL,
`Metadata_idMetadata` INT NOT NULL,
`VideoInformation_id` VARCHAR(11) NOT NULL,
PRIMARY KEY (`file_id`, `Metadata_idMetadata`, `VideoInformation_id`),
CONSTRAINT `fk_DownloadInformation_Metadata1`
FOREIGN KEY (`Metadata_idMetadata`)
REFERENCES `youtubemd`.`Metadata` (`idMetadata`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_DownloadInformation_VideoInformation1`
FOREIGN KEY (`VideoInformation_id`)
REFERENCES `youtubemd`.`VideoInformation` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
CREATE UNIQUE INDEX `file_id_UNIQUE` ON `youtubemd`.`DownloadInformation` (`file_id` ASC) VISIBLE;
SHOW WARNINGS;
CREATE INDEX `fk_DownloadInformation_Metadata1_idx` ON `youtubemd`.`DownloadInformation` (`Metadata_idMetadata` ASC) VISIBLE;
SHOW WARNINGS;
CREATE INDEX `fk_DownloadInformation_VideoInformation1_idx` ON `youtubemd`.`DownloadInformation` (`VideoInformation_id` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`DownloadStatistics`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`DownloadStatistics` (
`timesRequested` INT NOT NULL DEFAULT 0,
`DownloadInformation_file_id` VARCHAR(50) NOT NULL,
PRIMARY KEY (`DownloadInformation_file_id`),
CONSTRAINT `fk_DownloadStatistics_DownloadInformation1`
FOREIGN KEY (`DownloadInformation_file_id`)
REFERENCES `youtubemd`.`DownloadInformation` (`file_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`History`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`History` (
`User_id` INT(64) NOT NULL,
`DownloadInformation_file_id` VARCHAR(50) NOT NULL,
PRIMARY KEY (`User_id`, `DownloadInformation_file_id`),
CONSTRAINT `fk_History_User1`
FOREIGN KEY (`User_id`)
REFERENCES `youtubemd`.`User` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_History_DownloadInformation1`
FOREIGN KEY (`DownloadInformation_file_id`)
REFERENCES `youtubemd`.`DownloadInformation` (`file_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
CREATE INDEX `fk_History_DownloadInformation1_idx` ON `youtubemd`.`History` (`DownloadInformation_file_id` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`Metadata`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`Metadata` (
`idMetadata` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(100) NOT NULL,
`artist` VARCHAR(60) NOT NULL,
`cover` BLOB NOT NULL,
`duration` INT NULL,
`customMetadata` TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (`idMetadata`))
ENGINE = InnoDB
AUTO_INCREMENT = 0
CHECKSUM = 1;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`Playlist`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`Playlist` (
`id` VARCHAR(60) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
CREATE UNIQUE INDEX `id_UNIQUE` ON `youtubemd`.`Playlist` (`id` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`Playlist_has_VideoInformation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`Playlist_has_VideoInformation` (
`Playlist_id` VARCHAR(60) NOT NULL,
`VideoInformation_id` VARCHAR(11) NOT NULL,
PRIMARY KEY (`Playlist_id`, `VideoInformation_id`),
CONSTRAINT `fk_Playlist_has_VideoInformation_Playlist1`
FOREIGN KEY (`Playlist_id`)
REFERENCES `youtubemd`.`Playlist` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Playlist_has_VideoInformation_VideoInformation1`
FOREIGN KEY (`VideoInformation_id`)
REFERENCES `youtubemd`.`VideoInformation` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
CREATE INDEX `fk_Playlist_has_VideoInformation_VideoInformation1_idx` ON `youtubemd`.`Playlist_has_VideoInformation` (`VideoInformation_id` ASC) VISIBLE;
SHOW WARNINGS;
CREATE INDEX `fk_Playlist_has_VideoInformation_Playlist1_idx` ON `youtubemd`.`Playlist_has_VideoInformation` (`Playlist_id` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`PlaylistStatistics`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`PlaylistStatistics` (
`timesRequested` INT NOT NULL,
`Playlist_id` VARCHAR(60) NOT NULL,
PRIMARY KEY (`Playlist_id`),
CONSTRAINT `fk_PlaylistStatistics_Playlist1`
FOREIGN KEY (`Playlist_id`)
REFERENCES `youtubemd`.`Playlist` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`Preferences`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`Preferences` (
`language` VARCHAR(3) NOT NULL DEFAULT 'en',
`audioQuality` ENUM('320k', '256k', '128k') NOT NULL DEFAULT '128k',
`audioSampling` ENUM('44000', '48000') NOT NULL DEFAULT '44000',
`sendSongLinks` TINYINT NOT NULL DEFAULT 0,
`askForMetadata` TINYINT NOT NULL DEFAULT 1,
`User_id` INT(64) NOT NULL,
PRIMARY KEY (`User_id`),
CONSTRAINT `fk_Preferences_User`
FOREIGN KEY (`User_id`)
REFERENCES `youtubemd`.`User` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`User`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`User` (
`id` INT(64) NOT NULL DEFAULT 0,
`name` VARCHAR(45) NULL DEFAULT 'User',
`surname` VARCHAR(45) NULL,
`username` VARCHAR(45) NULL,
`lastSeen` DATETIME NOT NULL,
`firstUsage` DATETIME NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
CHECKSUM = 1
PACK_KEYS = 1;
SHOW WARNINGS;
CREATE UNIQUE INDEX `id_UNIQUE` ON `youtubemd`.`User` (`id` ASC) VISIBLE;
SHOW WARNINGS;
CREATE UNIQUE INDEX `username_UNIQUE` ON `youtubemd`.`User` (`username` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`VideoInformation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`VideoInformation` (
`id` VARCHAR(11) NOT NULL,
`title` VARCHAR(100) NOT NULL,
`channel` VARCHAR(60) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
CHECKSUM = 1;
SHOW WARNINGS;
CREATE UNIQUE INDEX `id_UNIQUE` ON `youtubemd`.`VideoInformation` (`id` ASC) VISIBLE;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `youtubemd`.`VideoStatistics`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `youtubemd`.`VideoStatistics` (
`timesRequested` INT NOT NULL DEFAULT 0,
`VideoInformation_id` VARCHAR(11) NOT NULL,
PRIMARY KEY (`VideoInformation_id`),
CONSTRAINT `fk_VideoStatistics_VideoInformation1`
FOREIGN KEY (`VideoInformation_id`)
REFERENCES `youtubemd`.`VideoInformation` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
CHECKSUM = 1;
-- SHOW WARNINGS;
--
-- SET [email protected]_SQL_MODE;
-- SET [email protected]_FOREIGN_KEY_CHECKS;
-- SET [email protected]_UNIQUE_CHECKS;
-- MySQL Script generated by MySQL Workbench
-- jue 25 jul 2019 13:50:06 CEST
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
-- SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
-- SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
-- SET @[email protected]@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema youtubemd
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema youtubemd
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS "youtubemd" ;
-- SHOW WARNINGS;
-- USE "youtubemd" ;
--
-- -----------------------------------------------------
-- Table "youtubemd"."DownloadInformation"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."DownloadInformation" (
"file_id" VARCHAR(50) NOT NULL,
"audioQuality" ENUM('320k', '256k', '128k') NOT NULL,
"audioSampling" ENUM('44000', '48000') NULL,
"Metadata_idMetadata" INT NOT NULL,
"VideoInformation_id" VARCHAR(11) NOT NULL,
PRIMARY KEY ("file_id", "Metadata_idMetadata", "VideoInformation_id"),
CONSTRAINT "fk_DownloadInformation_Metadata1"
FOREIGN KEY ("Metadata_idMetadata")
REFERENCES "youtubemd"."Metadata" ("idMetadata")
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT "fk_DownloadInformation_VideoInformation1"
FOREIGN KEY ("VideoInformation_id")
REFERENCES "youtubemd"."VideoInformation" ("id")
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CHECKSUM = 1;
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
-- -----------------------------------------------------
-- Table "youtubemd"."DownloadStatistics"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."DownloadStatistics" (
"timesRequested" INT NOT NULL DEFAULT 0,
"DownloadInformation_file_id" VARCHAR(50) NOT NULL,
PRIMARY KEY ("DownloadInformation_file_id"),
CONSTRAINT "fk_DownloadStatistics_DownloadInformation1"
FOREIGN KEY ("DownloadInformation_file_id")
REFERENCES "youtubemd"."DownloadInformation" ("file_id")
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CHECKSUM = 1;
-- SHOW WARNINGS;
-- -----------------------------------------------------
-- Table "youtubemd"."History"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."History" (
"User_id" INT NOT NULL,
"DownloadInformation_file_id" VARCHAR(50) NOT NULL,
PRIMARY KEY ("User_id", "DownloadInformation_file_id"),
CONSTRAINT "fk_History_User1"
FOREIGN KEY ("User_id")
REFERENCES "youtubemd"."User" ("id")
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT "fk_History_DownloadInformation1"
FOREIGN KEY ("DownloadInformation_file_id")
REFERENCES "youtubemd"."DownloadInformation" ("file_id")
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CHECKSUM = 1;
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
-- -----------------------------------------------------
-- Table "youtubemd"."Metadata"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."Metadata" (
"idMetadata" INT NOT NULL ,
"title" VARCHAR(100) NOT NULL,
"artist" VARCHAR(60) NOT NULL,
"cover" BLOB NOT NULL,
"duration" INT NULL,
"customMetadata" TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY ("idMetadata"));
CHECKSUM = 1;
-- SHOW WARNINGS;
-- -----------------------------------------------------
-- Table "youtubemd"."Playlist"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."Playlist" (
"id" VARCHAR(60) NOT NULL,
PRIMARY KEY ("id"));
CHECKSUM = 1;
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
-- -----------------------------------------------------
-- Table "youtubemd"."Playlist_has_VideoInformation"
-- -----------------------------------------------------
CREATE TABLE "youtubemd"."Playlist_has_VideoInformation" (
"Playlist_id" VARCHAR(60) NOT NULL,
"VideoInformation_id" VARCHAR(11) NOT NULL,
PRIMARY KEY ("Playlist_id", "VideoInformation_id"),
CONSTRAINT "fk_Playlist_has_VideoInformation_Playlist1"
FOREIGN KEY ("Playlist_id")
REFERENCES "youtubemd"."Playlist" ("id")
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT "fk_Playlist_has_VideoInformation_VideoInformation1"
FOREIGN KEY ("VideoInformation_id")
REFERENCES "youtubemd"."VideoInformation" ("id")
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CHECKSUM = 1;
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
--
-- SHOW WARNINGS;
-- -----------------------------------------------------