From 0972fa6eab8c9111311f082ba8abfdc6b4a40945 Mon Sep 17 00:00:00 2001
From: nil <nil@tfwhyno.gf>
Date: Wed, 2 Oct 2024 17:48:56 +0200
Subject: commit changes

---
 scripts/create_db.sql | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 scripts/create_db.sql

(limited to 'scripts/create_db.sql')

diff --git a/scripts/create_db.sql b/scripts/create_db.sql
new file mode 100644
index 0000000..f803714
--- /dev/null
+++ b/scripts/create_db.sql
@@ -0,0 +1,41 @@
+CREATE DATABASE IF NOT EXISTS balalaika;
+USE balalaika;
+
+DROP TABLE IF EXISTS song;
+DROP TABLE IF EXISTS album;
+DROP TABLE IF EXISTS artist;
+
+CREATE TABLE artist (
+    id int NOT NULL AUTO_INCREMENT,
+    name varchar(255),
+
+    PRIMARY KEY (id)
+);
+
+CREATE TABLE album (
+    id int NOT NULL AUTO_INCREMENT,
+    name varchar(255),
+    cover varchar(510),
+    artist_id int,
+
+    PRIMARY KEY (id),
+    FOREIGN KEY (artist_id) REFERENCES artist(id)
+);
+
+CREATE TABLE song (
+    id int NOT NULL AUTO_INCREMENT,
+    name varchar(255),
+    lyrics TEXT,
+
+    album_id int,
+
+    PRIMARY KEY (id),
+    FOREIGN KEY (album_id) REFERENCES album(id)
+);
+
+ALTER TABLE song CONVERT TO CHARACTER SET utf8;
+ALTER TABLE album CONVERT TO CHARACTER SET utf8;
+ALTER TABLE artist CONVERT TO CHARACTER SET utf8;
+
+GRANT ALL PRIVILEGES ON balalaika.* TO 'balalaika_user'@'%' WITH GRANT OPTION;
+FLUSH PRIVILEGES;
-- 
cgit v1.2.3

