diff --git a/initdb/schema.sql b/initdb/schema.sql index 802ca77450d8e48191400cb451534013f58d7e04..dde59cf1175b9c54897f17ea8bfe88cfb7787162 100644 --- a/initdb/schema.sql +++ b/initdb/schema.sql @@ -20,7 +20,35 @@ CREATE TABLE videos( created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, fileName text NOT NULL, PRIMARY KEY(id), - FOREIGN KEY (creator_id) REFERENCES users(id) + FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE CASCADE +); + +CREATE TABLE comments ( + id INT PRIMARY KEY AUTO_INCREMENT, + user_id int NOT NULL, + video_id int NOT NULL, + content text NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (video_id) REFERENCES videos(id) ON DELETE CASCADE +); + +CREATE TABLE reply ( + id INT PRIMARY KEY AUTO_INCREMENT, + creator_id int NOT NULL, + content text NOT NULL, + comment_id int NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (comment_id) REFERENCES comments(id) ON DELETE CASCADE, + FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE CASCADE +); + +CREATE TABLE reply_likes( + id INT PRIMARY KEY AUTO_INCREMENT, + reply_id INT NOT NULL, + user_id INT NOT NULL, + FOREIGN KEY (reply_id) REFERENCES reply(id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE TABLE likes ( id INT AUTO_INCREMENT PRIMARY KEY, diff --git a/package-lock.json b/package-lock.json index 27ce9ac5ad2a363bffa0f1853a69b24312f878a5..96723452868f71daeadac39705cf2f6ffd4ccfbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -60,6 +60,7 @@ "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", + "cross-env": "^7.0.3", "eslint": "^9.17.0", "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.16", @@ -3592,6 +3593,25 @@ "node": ">= 0.10" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 496a026c223d167beabedbd1be8d5bde47756846..2e651ee06926fd8f833bdab862d3469a2d0d65ab 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", + "cross-env": "^7.0.3", "eslint": "^9.17.0", "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.16",