Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit 2195d9c

Browse files
committed
Prepare for postgresql migration
1 parent a679afd commit 2195d9c

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

velog-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"migrate": "NODE_PATH=src babel-node src/scripts/migrate --plugins transform-es2015-modules-commonjs,transform-object-rest-spread,transform-async-to-generator --presets flow",
99
"deploy:dev": "sls deploy --stage dev",
1010
"deploy": "sls deploy --stage prod",
11-
"deploy:local": "./scripts/loadenv && sls deploy --stage prod",
11+
"deploy:local": ". ./scripts/loadenv && sls deploy --stage prod",
1212
"prettier:watch": "onchange '**/*.js' -- prettier-eslint --write {{changed}}"
1313
},
1414
"devDependencies": {

velog-backend/serverless.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ provider:
1919
REDIS_HOST: ${env:REDIS_HOST}
2020
REDIS_PASS: ${env:REDIS_PASS}
2121
INTERNAL_KEY: ${env:INTERNAL_KEY}
22+
POSTGRES_HOST: ${env:POSTGRES_HOST}
23+
POSTGRES_USER: ${env:POSTGRES_USER}
24+
POSTGRES_PW: ${env:POSTGRES_PW}
2225
NODE_ENV: "production"
2326
iamRoleStatements:
2427
- Effect: "Allow"
@@ -65,6 +68,7 @@ functions:
6568
vpc:
6669
securityGroupIds:
6770
- sg-5bc57830
71+
- sg-056b9986a73e2f766
6872
subnetIds:
6973
- subnet-91481ef9
7074
- subnet-4f59dc03

velog-backend/src/database/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const {
1212
POSTGRES_PW,
1313
} = process.env;
1414
const db: Sequelize = new Sequelize('velog', POSTGRES_USER, POSTGRES_PW, {
15-
host: 'localhost',
15+
host: POSTGRES_HOST || '',
1616
dialect: 'postgres',
1717
define: {
1818
underscored: true,

velog-backend/src/database/models/PostsTags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ PostsTags.getPostsCount = async ({ userId }: GetPostsCountParams) => {
9292
INNER JOIN posts AS p ON p.id = pt.fk_post_id
9393
WHERE p.fk_user_id = $userId
9494
AND p.is_temp = FALSE
95-
) GROUP BY tag
95+
) as q GROUP BY tag
9696
ORDER BY count DESC, tag
9797
`;
9898
try {

0 commit comments

Comments
 (0)