Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit b09249e

Browse files
authored
Merge pull request #80 from swibly/develop
2 parents 3ed63c3 + 20380b4 commit b09249e

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

.env.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Postgres Config
2+
POSTGRES_HOST=swibly-api-db
3+
POSTGRES_USER=swibly
4+
POSTGRES_PASSWORD=123456
5+
POSTGRES_DATABASE=swiblydb
6+
POSTGRES_PORT=5432
7+
28
# Connection string can be found in the PSQL provider (or locally)
3-
POSTGRES_CONNECTION_STRING=
9+
POSTGRES_CONNECTION_STRING=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
410

511
# API Config
612
JWT_SECRET=jwtsecret
713
ENVIRONMENT=local
14+
API_HOST=127.0.0.1
15+
API_PORT=8080
816

917
# TIP: You can generate a JWT_SECRET with the command:
1018
# openssl rand -hex 256
@@ -19,10 +27,3 @@ SMTP_PASSWORD=
1927
# S3 Bucket configuration
2028
S3_ACCESS_KEY=
2129
S3_SECRET_KEY=
22-
23-
# Local Postgres usage only
24-
DEBUG_POSTGRES_CONTAINER_NAME=swiblydb-container
25-
DEBUG_POSTGRES_HOST=localhost
26-
DEBUG_POSTGRES_USER=swibly
27-
DEBUG_POSTGRES_PASSWORD=123456
28-
DEBUG_POSTGRES_DATABASE=swiblydb

docker-compose.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
services:
2+
swibly-api:
3+
container_name: swibly-api
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
env_file:
8+
- .env
9+
ports:
10+
- '$API_HOST:$API_PORT:8080'
11+
networks:
12+
- "swibly_internal"
13+
- "swibly_external"
14+
depends_on:
15+
- "postgres"
16+
restart: unless-stopped
17+
218
postgres:
319
image: postgres:latest
4-
container_name: $DEBUG_POSTGRES_CONTAINER_NAME
20+
container_name: swibly-api-db
521
environment:
6-
POSTGRES_DB: $DEBUG_POSTGRES_DATABASE
7-
POSTGRES_USER: $DEBUG_POSTGRES_USER
8-
POSTGRES_PASSWORD: $DEBUG_POSTGRES_PASSWORD
22+
POSTGRES_DB: $POSTGRES_DATABASE
23+
POSTGRES_USER: $POSTGRES_USER
24+
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
925
env_file:
1026
- .env
11-
ports:
12-
- '5432:5432'
1327
volumes:
1428
- ./pgdata:/var/lib/postgresql/data
29+
networks:
30+
- "swibly_internal"
31+
restart: unless-stopped
32+
33+
networks:
34+
swibly_internal:
35+
internal: true
36+
swibly_external:

internal/service/repository/project.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,11 @@ func (pr *projectRepository) Create(createModel *dto.ProjectCreation) (uint, err
243243
}
244244

245245
if createModel.Fork != nil {
246-
fork, err := pr.Get(createModel.OwnerID, &model.Project{ID: *createModel.Fork})
247-
if err != nil {
248-
tx.Rollback()
249-
return 0, err
246+
var userID uint
247+
if err := tx.Model(&model.ProjectOwner{}).Where("project_id = ?", createModel.Fork).Pluck("user_id", userID); err != nil {
250248
}
251249

252-
if err := tx.Create(&model.ProjectUserPermission{ProjectID: fork.ID, UserID: fork.OwnerID, Allow: dto.Allow{View: true}}).Error; err != nil {
250+
if err := tx.Create(&model.ProjectUserPermission{ProjectID: project.ID, UserID: userID, Allow: dto.Allow{View: true}}).Error; err != nil {
253251
tx.Rollback()
254252
return 0, err
255253
}

0 commit comments

Comments
 (0)