Skip to content

Commit

Permalink
chore: model 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
권아림 committed Jul 26, 2024
1 parent 2014ef3 commit 4c2a6cc
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 4 deletions.
46 changes: 46 additions & 0 deletions friends/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
],
),
]
9 changes: 8 additions & 1 deletion friends/models.py
Original file line number Diff line number Diff line change
@@ -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)
48 changes: 48 additions & 0 deletions restaurants/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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)),
],
),
]
18 changes: 17 additions & 1 deletion restaurants/models.py
Original file line number Diff line number Diff line change
@@ -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)
75 changes: 75 additions & 0 deletions reviews/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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"
),
),
],
),
]
20 changes: 19 additions & 1 deletion reviews/models.py
Original file line number Diff line number Diff line change
@@ -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()
31 changes: 31 additions & 0 deletions users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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)),
],
),
]
10 changes: 9 additions & 1 deletion users/models.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4c2a6cc

Please sign in to comment.