-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### πΌ Update Version - v10.1.1 #### π Fix Bug - Fix database import bug - Correct variable name in users.route.ts #### π Refactoring Code - Fix Database Connection
- Loading branch information
Showing
24 changed files
with
279 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import { Client } from 'pg'; | ||
import { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE } from '@config'; | ||
import { POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB } from '@config'; | ||
|
||
export const client = new Client({ | ||
connectionString: `postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}`, | ||
connectionString: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}`, | ||
}); | ||
|
||
client.connect(); | ||
|
||
export default client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,13 @@ | ||
-- TABLE μ‘΄μ¬ν κ²½μ° μμ | ||
DROP TABLE IF EXISTS teachers cascade; | ||
DROP TABLE IF EXISTS classes cascade; | ||
DROP TABLE IF EXISTS students cascade; | ||
DROP TABLE IF EXISTS classes_category cascade; | ||
DROP TABLE IF EXISTS enrolment cascade; | ||
|
||
-- ============ | ||
-- κ°μ¬ ν μ΄λΈ | ||
-- ============ | ||
-- κ°μ¬ ν μ΄λΈ μμ± | ||
CREATE TABLE teachers( | ||
"teacherId" SERIAL PRIMARY KEY, | ||
-- κ°μ¬ ID | ||
"teacherName" VARCHAR(32) NOT NULL, | ||
-- κ°μ¬λͺ | ||
"teacherAbout" VARCHAR(48) -- κ°μ¬ μ 보 | ||
); | ||
-- κ°μ¬ λ°μ΄ν° μμ± | ||
INSERT INTO teachers( | ||
"teacherId", | ||
"teacherName", | ||
"teacherAbout" | ||
) | ||
VALUES (1, 'μ‘°νμ', 'μΉ κ°λ° κ°μ¬'), | ||
(2, 'κ°λ³΅μΉκ°λ°μ', 'μλλ‘μ΄λ μ½νλ¦° κ°μ¬'), | ||
(3, 'μ΄κ³ μ', 'μνμ½λ© μ΄μμ§ κ²Έ κ°μ¬'), | ||
(4, 'κΉνμ', 'νμ΄μ¬ μκ³ λ¦¬μ¦ κ°μ¬'), | ||
(5, 'μ€μ¬μ±', 'Kotiln κΈ°λ° μλλ‘μ΄λ κ°μ¬'), | ||
(6, 'μ‘°ν', 'μΏ λ²λ€ν°μ€ κ°μ¬'), | ||
(7, 'Rookiss', 'μΌλ¦¬μΈ μμ§ μ λ¬Έ κ°μ¬'), | ||
(8, 'μ μ©νITνμ΅', 'SQLD μκ²©μ¦ μ·¨λ κ°μ¬'), | ||
(9, 'κΉνλ―Ό', 'μΏ λ²λ€ν°μ€ κ°μ¬'), | ||
(10, 'ν°λ', 'μκ³ λ¦¬μ¦ κ°μ¬'); | ||
SELECT SETVAL( | ||
'"teachers_teacherId_seq"', | ||
( | ||
SELECT max("teacherId") | ||
FROM teachers | ||
) | ||
); | ||
-- =================== | ||
-- κ°μ μΉ΄ν κ³ λ¦¬ ν μ΄λΈ | ||
-- =================== | ||
-- κ°μ μΉ΄ν κ³ λ¦¬ ν μ΄λΈ μμ± | ||
CREATE TABLE classes_category( | ||
"categoryId" SERIAL PRIMARY KEY, | ||
-- μΉ΄ν κ³ λ¦¬ ID | ||
"categoryName" VARCHAR(32) UNIQUE NOT NULL -- μΉ΄ν κ³ λ¦¬ λͺ | ||
); | ||
-- κ°μ μΉ΄ν κ³ λ¦¬ λ°μ΄ν° μμ± | ||
INSERT INTO classes_category("categoryId", "categoryName") | ||
VALUES (1, 'μΉ'), | ||
(2, 'μ±'), | ||
(3, 'κ²μ'), | ||
(4, 'μκ³ λ¦¬μ¦'), | ||
(5, 'μΈνλΌ'), | ||
(6, 'λ°μ΄ν°λ² μ΄μ€'); | ||
SELECT SETVAL( | ||
'"classes_category_categoryId_seq"', | ||
( | ||
SELECT max("categoryId") | ||
FROM classes_category | ||
) | ||
); | ||
-- ============ | ||
-- κ°μ ν μ΄λΈ | ||
-- ============ | ||
-- κ°μ ν μ΄λΈ μμ± | ||
CREATE TABLE classes( | ||
"classId" SERIAL PRIMARY KEY, | ||
-- κ°μ ID | ||
"className" VARCHAR(32) UNIQUE NOT NULL, | ||
-- κ°μλͺ | ||
"classPrice" INTEGER NOT NULL DEFAULT 0, | ||
-- κ°κ²© | ||
"introduce" TEXT, | ||
-- κ°μ μκ° | ||
"active" BOOLEAN NOT NULL DEFAULT false, | ||
-- κ°μ νμ±ν (true: 곡κ°, false, λΉκ³΅κ°) | ||
-- If Exists Table Drop | ||
DROP TABLE IF EXISTS users cascade; | ||
-- ================ | ||
-- TABLE [users] | ||
-- ================ | ||
-- create users table | ||
CREATE TABLE users( | ||
"id" SERIAL PRIMARY KEY, | ||
"email" VARCHAR(32) UNIQUE NOT NULL, | ||
"password" VARCHAR(48) NOT NULL, | ||
"createdAt" TIMESTAMP WITHOUT TIME ZONE DEFAULT(NOW() AT TIME ZONE 'utc'), | ||
-- κ°μ μμ± μΌμ | ||
"updatedAt" TIMESTAMP WITHOUT TIME ZONE, | ||
-- κ°μ μμ μΌμ | ||
"teacherId" INTEGER REFERENCES teachers("teacherId") ON DELETE CASCADE, | ||
-- κ°μ¬ ID | ||
"categoryId" INTEGER REFERENCES classes_category("categoryId") ON DELETE CASCADE -- κ°μ¬ ID | ||
); | ||
-- ============== | ||
-- μκ°μ ν μ΄λΈ | ||
-- ============== | ||
-- μκ°μ ν μ΄λΈ μμ± | ||
CREATE TABLE students( | ||
"studentId" SERIAL PRIMARY KEY, | ||
-- μκ°μ ID | ||
"email" VARCHAR(48) UNIQUE NOT NULL, | ||
-- μκ°μ μ΄λ©μΌ | ||
"nickname" VARCHAR(32) NOT NULL -- μκ°μ λλ€μ | ||
); | ||
-- =============== | ||
-- μκ°μ μ² ν μ΄λΈ | ||
-- =============== | ||
-- μκ°μ μ² ν μ΄λΈ μμ± | ||
CREATE TABLE enrolment( | ||
"classId" INTEGER REFERENCES classes("classId") ON DELETE CASCADE, | ||
-- κ°μ ID | ||
"studentId" INTEGER REFERENCES students("studentId") ON DELETE CASCADE, | ||
-- μκ°μ ID | ||
"applicationAt" TIMESTAMP WITHOUT TIME ZONE DEFAULT(NOW() AT TIME ZONE 'utc') -- μ μ² μΌμ | ||
"updatedAt" TIMESTAMP WITHOUT TIME ZONE | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.