diff --git a/friends/migrations/0001_initial.py b/friends/migrations/0001_initial.py new file mode 100644 index 0000000..e0ad404 --- /dev/null +++ b/friends/migrations/0001_initial.py @@ -0,0 +1,46 @@ +# Generated by Django 4.2.14 on 2024-07-26 14:19 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ("users", "0001_initial"), + ] + + operations = [ + migrations.CreateModel( + name="Friend", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("state", models.CharField(blank=True, max_length=20, null=True)), + ( + "friend", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="friend_of", + to="users.user", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="friends", + to="users.user", + ), + ), + ], + ), + ] diff --git a/friends/models.py b/friends/models.py index 0b4331b..504a075 100644 --- a/friends/models.py +++ b/friends/models.py @@ -1,3 +1,10 @@ -# from django.db import models +from django.db import models +from users.models import User # Create your models here. + + +class Friend(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="friends") + friend = models.ForeignKey(User, on_delete=models.CASCADE, related_name="friend_of") + state = models.CharField(max_length=20, null=True, blank=True) diff --git a/restaurants/migrations/0001_initial.py b/restaurants/migrations/0001_initial.py new file mode 100644 index 0000000..39d9b8d --- /dev/null +++ b/restaurants/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# Generated by Django 4.2.14 on 2024-07-26 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="Restaurant", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=255)), + ( + "rating_naver", + models.DecimalField( + blank=True, decimal_places=2, max_digits=5, null=True + ), + ), + ( + "rating_kakao", + models.DecimalField( + blank=True, decimal_places=2, max_digits=5, null=True + ), + ), + ( + "rating_google", + models.DecimalField( + blank=True, decimal_places=2, max_digits=5, null=True + ), + ), + ("address", models.CharField(max_length=255)), + ("latitude", models.DecimalField(decimal_places=7, max_digits=10)), + ("longitude", models.DecimalField(decimal_places=7, max_digits=10)), + ], + ), + ] diff --git a/restaurants/models.py b/restaurants/models.py index 0b4331b..901401b 100644 --- a/restaurants/models.py +++ b/restaurants/models.py @@ -1,3 +1,19 @@ -# from django.db import models +from django.db import models # Create your models here. + + +class Restaurant(models.Model): + name = models.CharField(max_length=255) + rating_naver = models.DecimalField( + max_digits=5, decimal_places=2, null=True, blank=True + ) + rating_kakao = models.DecimalField( + max_digits=5, decimal_places=2, null=True, blank=True + ) + rating_google = models.DecimalField( + max_digits=5, decimal_places=2, null=True, blank=True + ) + address = models.CharField(max_length=255) + latitude = models.DecimalField(max_digits=10, decimal_places=7) + longitude = models.DecimalField(max_digits=10, decimal_places=7) diff --git a/reviews/migrations/0001_initial.py b/reviews/migrations/0001_initial.py new file mode 100644 index 0000000..c616e18 --- /dev/null +++ b/reviews/migrations/0001_initial.py @@ -0,0 +1,75 @@ +# Generated by Django 4.2.14 on 2024-07-26 14:19 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ("users", "0001_initial"), + ("restaurants", "0001_initial"), + ] + + operations = [ + migrations.CreateModel( + name="Review", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("content", models.CharField(max_length=255)), + ("recommend_count", models.IntegerField()), + ("decommend_count", models.IntegerField()), + ("parent_id", models.IntegerField(blank=True, null=True)), + ("date", models.DateTimeField()), + ( + "restaurant", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="restaurants.restaurant", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="users.user" + ), + ), + ], + ), + migrations.CreateModel( + name="Recommend", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("recommend", models.BooleanField()), + ( + "review", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="reviews.review" + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="users.user" + ), + ), + ], + ), + ] diff --git a/reviews/models.py b/reviews/models.py index 0b4331b..1ffa83d 100644 --- a/reviews/models.py +++ b/reviews/models.py @@ -1,3 +1,21 @@ -# from django.db import models +from django.db import models +from users.models import User +from restaurants.models import Restaurant # Create your models here. + + +class Review(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE) + content = models.CharField(max_length=255) + recommend_count = models.IntegerField() + decommend_count = models.IntegerField() + parent_id = models.IntegerField(null=True, blank=True) + date = models.DateTimeField() + + +class Recommend(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + review = models.ForeignKey(Review, on_delete=models.CASCADE) + recommend = models.BooleanField() diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py new file mode 100644 index 0000000..b5b9347 --- /dev/null +++ b/users/migrations/0001_initial.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.14 on 2024-07-26 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="User", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("email", models.CharField(max_length=255)), + ("password", models.CharField(max_length=255)), + ("nickname", models.CharField(blank=True, max_length=255, null=True)), + ("image", models.CharField(blank=True, max_length=255, null=True)), + ("reliability", models.SmallIntegerField(blank=True, null=True)), + ], + ), + ] diff --git a/users/models.py b/users/models.py index 0b4331b..b061854 100644 --- a/users/models.py +++ b/users/models.py @@ -1,3 +1,11 @@ -# from django.db import models +from django.db import models # Create your models here. + + +class User(models.Model): + email = models.CharField(max_length=255) + password = models.CharField(max_length=255) + nickname = models.CharField(max_length=255, null=True, blank=True) + image = models.CharField(max_length=255, null=True, blank=True) + reliability = models.SmallIntegerField(null=True, blank=True)