Skip to content

Commit

Permalink
feat: RDS로 다시 회귀
Browse files Browse the repository at this point in the history
  • Loading branch information
sejokim committed Mar 30, 2024
1 parent 34d9e53 commit b784c95
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 36 deletions.
26 changes: 26 additions & 0 deletions backend/friends/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.10 on 2024-03-30 10:44

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Friend',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.PositiveSmallIntegerField(choices=[(0, '대기'), (1, '수락'), (2, '거절')], default=0)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'db_table': 'friends',
},
),
]
32 changes: 32 additions & 0 deletions backend/friends/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.10 on 2024-03-30 10:44

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('friends', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name='friend',
name='friend_id',
field=models.ForeignKey(db_column='friend_id', on_delete=django.db.models.deletion.PROTECT, related_name='friend_who_is_requested', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='friend',
name='user_id',
field=models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.PROTECT, related_name='user_who_is_requesting', to=settings.AUTH_USER_MODEL),
),
migrations.AlterUniqueTogether(
name='friend',
unique_together={('user_id', 'friend_id')},
),
]
89 changes: 89 additions & 0 deletions backend/games/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Generated by Django 4.2.10 on 2024-03-30 10:44

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='CasualGameListView',
fields=[
('game_id', models.IntegerField(primary_key=True, serialize=False)),
('mode', models.PositiveSmallIntegerField()),
('status', models.PositiveSmallIntegerField()),
],
options={
'db_table': 'casual_game_list_view',
'managed': False,
},
),
migrations.CreateModel(
name='CasualGameView',
fields=[
('game_id', models.IntegerField(primary_key=True, serialize=False)),
('mode', models.PositiveSmallIntegerField()),
],
options={
'db_table': 'casual_game_view',
'managed': False,
},
),
migrations.CreateModel(
name='GameRecordView',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('game_id', models.IntegerField()),
('mode', models.IntegerField()),
('user_id', models.IntegerField()),
('started_at', models.DateTimeField(auto_now_add=True)),
],
options={
'db_table': 'game_record_view',
'managed': False,
},
),
migrations.CreateModel(
name='RankGameView',
fields=[
('game_id', models.IntegerField(primary_key=True, serialize=False)),
],
options={
'db_table': 'rank_game_view',
'managed': False,
},
),
migrations.CreateModel(
name='Game',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.PositiveSmallIntegerField(choices=[(0, 'casual_1vs1'), (1, 'casual_tournament'), (2, 'rank')])),
('title', models.CharField(blank=True, null=True)),
('password', models.CharField(blank=True, null=True)),
('status', models.PositiveSmallIntegerField(choices=[(0, 'AVAILABLE_WAITING'), (1, 'FULL_WAITING'), (2, 'IN_GAME'), (3, 'FINISHED'), (4, 'DELETED')])),
('created_at', models.DateTimeField(auto_now_add=True)),
('started_at', models.DateTimeField(blank=True, null=True)),
],
options={
'db_table': 'games',
},
),
migrations.CreateModel(
name='Result',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('player1_score', models.PositiveSmallIntegerField(blank=True, null=True)),
('player2_score', models.PositiveSmallIntegerField(blank=True, null=True)),
('started_at', models.DateTimeField(blank=True, null=True)),
('playtime', models.TimeField(blank=True, null=True)),
],
options={
'db_table': 'results',
},
),
]
68 changes: 68 additions & 0 deletions backend/games/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.2.10 on 2024-03-30 10:44

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('games', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name='result',
name='player1',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_player1', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='result',
name='player2',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_player2', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='result',
name='winner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='game',
name='manager',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='game',
name='match1',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match1', to='games.result'),
),
migrations.AddField(
model_name='game',
name='match2',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match2', to='games.result'),
),
migrations.AddField(
model_name='game',
name='match3',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match3', to='games.result'),
),
migrations.AddField(
model_name='game',
name='player1',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player1_id', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='game',
name='player2',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player2_id', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='game',
name='player3',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player3_id', to=settings.AUTH_USER_MODEL),
),
]
26 changes: 13 additions & 13 deletions backend/src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ def wait_for_vault_client(client, retries=5, delay=5):
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '/var/log/djangolog/django.log',
},
# 'file': {
# 'level': 'INFO',
# 'class': 'logging.FileHandler',
# 'filename': '/var/log/djangolog/django.log',
# },
},
'loggers': {
'': {
'handlers': ['console', 'file'],
# 'handlers': ['console'],
# 'handlers': ['console', 'file'],
'handlers': ['console'],
'level': 'INFO',
'propagate': True,
},
'django': {
'handlers': ['console', 'file'],
# 'handlers': ['console'],
# 'handlers': ['console', 'file'],
'handlers': ['console'],
'level': 'INFO',
'propagate': True,
},
Expand Down Expand Up @@ -230,8 +230,8 @@ def wait_for_vault_client(client, retries=5, delay=5):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'db_name',
'USER': env('POSTGRES_USER'),
'NAME': 'transcendence',
'USER': 'sejokim',
'PASSWORD': env('POSTGRES_PASSWORD'),
'HOST': env('DB_HOST'),
'PORT': env('DB_PORT'),
Expand All @@ -241,8 +241,8 @@ def wait_for_vault_client(client, retries=5, delay=5):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'db_name',
'USER': env('POSTGRES_USER'),
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': env('POSTGRES_PASSWORD'),
'HOST': env('DB_HOST'),
'PORT': env('DB_PORT'),
Expand Down
39 changes: 39 additions & 0 deletions backend/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.10 on 2024-03-30 10:44

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='이메일 주소')),
('nickname', models.CharField(blank=True, max_length=8, null=True, unique=True)),
('rating', models.PositiveIntegerField(default=0)),
('avatar', models.ImageField(null=True, upload_to='avatar/')),
('verification_code', models.CharField(blank=True, max_length=6, null=True)),
('is_online', models.BooleanField(default=False)),
('custom_1vs1_wins', models.IntegerField(default=0)),
('custom_tournament_wins', models.IntegerField(default=0)),
('rank_wins', models.IntegerField(default=0)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'db_table': 'users',
},
),
]
39 changes: 18 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,25 @@ services:
VAULT_URL: "https://hashicorp_vault:8200"
VAULT_TOKEN: ${VAULT_TOKEN}
BASE_URL: ${BASE_URL}
depends_on:
postgresql:
condition: service_healthy

postgresql:
build:
context: ./db
dockerfile: Dockerfile
container_name: db_container
ports:
- 5432:5432
volumes:
- "${POSTGRES_DATA}:/var/lib/postgresql/data"
env_file:
- .env
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app_network
# postgresql:
# build:
# context: ./db
# dockerfile: Dockerfile
# container_name: db_container
# ports:
# - 5432:5432
# volumes:
# - "${POSTGRES_DATA}:/var/lib/postgresql/data"
# env_file:
# - .env
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
# interval: 10s
# timeout: 5s
# retries: 5
# networks:
# - app_network

nginx:
build: ./nginx
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/global.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const devBackend = "http://localhost:8000/api";
const devWebSocket = "ws://localhost:8000/ws";
const prodBackend = "https://10.14.5.2:443/api";
const prodWebSocket = "wss://10.14.5.2:443/ws";
const prodBackend = "https://localhost:443/api";
const prodWebSocket = "wss://localhost:443/ws";

const getAPIUrl = () => {
return window.mode === "dev" ? devBackend : prodBackend;
Expand Down

0 comments on commit b784c95

Please sign in to comment.