diff --git a/backend/friends/migrations/0001_initial.py b/backend/friends/migrations/0001_initial.py new file mode 100644 index 000000000..51c516bb2 --- /dev/null +++ b/backend/friends/migrations/0001_initial.py @@ -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', + }, + ), + ] diff --git a/backend/friends/migrations/0002_initial.py b/backend/friends/migrations/0002_initial.py new file mode 100644 index 000000000..cf7cac770 --- /dev/null +++ b/backend/friends/migrations/0002_initial.py @@ -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')}, + ), + ] diff --git a/backend/games/migrations/0001_initial.py b/backend/games/migrations/0001_initial.py new file mode 100644 index 000000000..08fd1e6da --- /dev/null +++ b/backend/games/migrations/0001_initial.py @@ -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', + }, + ), + ] diff --git a/backend/games/migrations/0002_initial.py b/backend/games/migrations/0002_initial.py new file mode 100644 index 000000000..e50a32237 --- /dev/null +++ b/backend/games/migrations/0002_initial.py @@ -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), + ), + ] diff --git a/backend/src/settings.py b/backend/src/settings.py index a517029e6..96c981fa3 100644 --- a/backend/src/settings.py +++ b/backend/src/settings.py @@ -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, }, @@ -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'), @@ -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'), diff --git a/backend/users/migrations/0001_initial.py b/backend/users/migrations/0001_initial.py new file mode 100644 index 000000000..fb965848c --- /dev/null +++ b/backend/users/migrations/0001_initial.py @@ -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', + }, + ), + ] diff --git a/docker-compose.yml b/docker-compose.yml index dfa15e39e..638f63ab2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/frontend/src/global.js b/frontend/src/global.js index 28bb4377f..5ef4c2521 100644 --- a/frontend/src/global.js +++ b/frontend/src/global.js @@ -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;