- 사람 글 큰 카드: 머리줄·4:5 본문(사진, 없으면 글을 크게)·좋아요·댓글·보내기 - 사람 글 댓글: 로그인한 사람만, comment 표에 talk_id, talk.comment_count (init.sql) - '오늘 내 글'·'동네 사람들'·주제별 묶음, '이번 주 가까운 행사' 띠 제거 - 행사 포스트 자리 최대 40개, 앞쪽 절반에 다 못 들어가면 끝까지 한 장씩 걸러 - GA: feed_item_view(talk·event 노출), talk_comment
541 lines
25 KiB
Python
541 lines
25 KiB
Python
import uuid
|
|
from datetime import date, datetime, time
|
|
from decimal import Decimal
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import BigInteger, Boolean, Date, DateTime, ForeignKey, Integer, LargeBinary, Numeric, SmallInteger, String, Text, Time, func
|
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
class Region(Base):
|
|
__tablename__ = "region"
|
|
|
|
code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(30))
|
|
short_name: Mapped[str] = mapped_column(String(20))
|
|
lat: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
lon: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
nx: Mapped[int] = mapped_column(SmallInteger)
|
|
ny: Mapped[int] = mapped_column(SmallInteger)
|
|
warning_zone_code: Mapped[str] = mapped_column(String(10))
|
|
mid_land_code: Mapped[str] = mapped_column(String(10))
|
|
mid_temp_code: Mapped[str] = mapped_column(String(10))
|
|
is_ranking_spot: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
ranking_note: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)
|
|
|
|
|
|
class WeatherHourly(Base):
|
|
__tablename__ = "weather_hourly"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
forecast_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), primary_key=True)
|
|
temp_c: Mapped[Decimal] = mapped_column(Numeric(4, 1))
|
|
feels_c: Mapped[Decimal] = mapped_column(Numeric(4, 1))
|
|
discomfort_index: Mapped[int] = mapped_column(SmallInteger)
|
|
sky: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_type: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_prob: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_mm: Mapped[Decimal] = mapped_column(Numeric(5, 1))
|
|
humidity: Mapped[int] = mapped_column(SmallInteger)
|
|
wind_ms: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
|
|
issued_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
|
|
|
|
class WeatherDaily(Base):
|
|
__tablename__ = "weather_daily"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
forecast_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
temp_min_c: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
|
|
temp_max_c: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
|
|
sky: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_type: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_prob: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_prob_am: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
rain_prob_pm: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
issued_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
|
|
|
|
class SunTime(Base):
|
|
__tablename__ = "sun_time"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
sun_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
sunrise_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
sunset_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
dusk_end_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
sunset_azimuth: Mapped[int] = mapped_column(SmallInteger)
|
|
|
|
|
|
class AirStation(Base):
|
|
__tablename__ = "air_station"
|
|
|
|
station_name: Mapped[str] = mapped_column(String(30), primary_key=True)
|
|
lat: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
lon: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
|
|
|
|
class AirQuality(Base):
|
|
__tablename__ = "air_quality"
|
|
|
|
station_name: Mapped[str] = mapped_column(String(30), primary_key=True)
|
|
pm25: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
pm10: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
grade: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
measured_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
|
|
|
|
class WeatherWarning(Base):
|
|
__tablename__ = "weather_warning"
|
|
|
|
warning_zone_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
warning_type: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
level: Mapped[int] = mapped_column(SmallInteger)
|
|
|
|
|
|
class CloudHourly(Base):
|
|
__tablename__ = "cloud_hourly"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
kind: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
distance_km: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
forecast_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), primary_key=True)
|
|
model: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
cloud_low: Mapped[int] = mapped_column(SmallInteger)
|
|
cloud_mid: Mapped[int] = mapped_column(SmallInteger)
|
|
cloud_high: Mapped[int] = mapped_column(SmallInteger)
|
|
|
|
|
|
class OpenMeteoHourly(Base):
|
|
__tablename__ = "openmeteo_hourly"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
forecast_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), primary_key=True)
|
|
uv_index: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 2), nullable=True)
|
|
uv_index_clear_sky: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 2), nullable=True)
|
|
visibility_m: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
|
wind_gust_ms: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
|
|
pressure_hpa: Mapped[Optional[Decimal]] = mapped_column(Numeric(5, 1), nullable=True)
|
|
soil_temp_c: Mapped[Optional[Decimal]] = mapped_column(Numeric(4, 1), nullable=True)
|
|
sunshine_s: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
shortwave_avg_wm2: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
shortwave_max_wm2: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
fetched_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
|
|
|
|
class SkyScore(Base):
|
|
__tablename__ = "sky_score"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
score_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
sky_type: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
score: Mapped[int] = mapped_column(SmallInteger)
|
|
grade: Mapped[int] = mapped_column(SmallInteger)
|
|
confidence: Mapped[int] = mapped_column(SmallInteger)
|
|
best_times: Mapped[list] = mapped_column(JSONB)
|
|
computed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
situation: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
models_total: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
models_agree: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
air: Mapped[Optional[dict]] = mapped_column(JSONB, nullable=True)
|
|
|
|
|
|
class SunsetSpot(Base):
|
|
__tablename__ = "sunset_spot"
|
|
|
|
spot_id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
region_code: Mapped[str] = mapped_column(String(10))
|
|
name: Mapped[str] = mapped_column(String(40))
|
|
description: Mapped[str] = mapped_column(String(100))
|
|
lat: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
lon: Mapped[Decimal] = mapped_column(Numeric(8, 5))
|
|
sort_order: Mapped[int] = mapped_column(SmallInteger, default=0)
|
|
|
|
|
|
class IndexDefinition(Base):
|
|
__tablename__ = "index_definition"
|
|
|
|
index_id: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
code: Mapped[str] = mapped_column(String(30), unique=True)
|
|
name: Mapped[str] = mapped_column(String(20))
|
|
icon: Mapped[str] = mapped_column(String(30))
|
|
category: Mapped[int] = mapped_column(SmallInteger)
|
|
is_fun: Mapped[bool] = mapped_column(Boolean)
|
|
is_core: Mapped[bool] = mapped_column(Boolean)
|
|
has_detail: Mapped[bool] = mapped_column(Boolean)
|
|
description: Mapped[str] = mapped_column(String(100))
|
|
windows: Mapped[list] = mapped_column(JSONB)
|
|
weight_temp: Mapped[int] = mapped_column(SmallInteger)
|
|
weight_rain: Mapped[int] = mapped_column(SmallInteger)
|
|
weight_wind: Mapped[int] = mapped_column(SmallInteger)
|
|
weight_humidity: Mapped[int] = mapped_column(SmallInteger)
|
|
weight_air: Mapped[int] = mapped_column(SmallInteger)
|
|
weight_uv: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
weight_sun: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
weight_view: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
weight_time: Mapped[int] = mapped_column(SmallInteger)
|
|
factor_rules: Mapped[dict] = mapped_column(JSONB)
|
|
zero_rules: Mapped[list] = mapped_column(JSONB)
|
|
limit_description: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
|
sentences: Mapped[dict] = mapped_column(JSONB)
|
|
sort_order: Mapped[int] = mapped_column(SmallInteger)
|
|
priority: Mapped[int] = mapped_column(SmallInteger, default=2, server_default="2")
|
|
months: Mapped[list] = mapped_column(JSONB, default=list, server_default="[]") # 제철 달. 비면 일 년 내내
|
|
|
|
|
|
class IndexScore(Base):
|
|
__tablename__ = "index_score"
|
|
|
|
region_code: Mapped[str] = mapped_column(String(10), primary_key=True)
|
|
score_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
index_id: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
score: Mapped[int] = mapped_column(SmallInteger)
|
|
summary: Mapped[str] = mapped_column(String(100))
|
|
temp_score: Mapped[int] = mapped_column(SmallInteger)
|
|
rain_score: Mapped[int] = mapped_column(SmallInteger)
|
|
wind_score: Mapped[int] = mapped_column(SmallInteger)
|
|
humidity_score: Mapped[int] = mapped_column(SmallInteger)
|
|
air_score: Mapped[int] = mapped_column(SmallInteger)
|
|
uv_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
sun_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
view_score: Mapped[int] = mapped_column(SmallInteger, default=0, server_default="0")
|
|
time_score: Mapped[int] = mapped_column(SmallInteger)
|
|
zero_reason: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
|
notes: Mapped[dict] = mapped_column(JSONB)
|
|
estimated: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
slots: Mapped[dict] = mapped_column(JSONB, default=dict, server_default="{}")
|
|
computed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
|
|
|
|
class Holiday(Base):
|
|
__tablename__ = "holiday"
|
|
|
|
holiday_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(20), primary_key=True)
|
|
|
|
|
|
class Place(Base):
|
|
__tablename__ = "place"
|
|
|
|
place_id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
region_code: Mapped[str] = mapped_column(String(10))
|
|
area: Mapped[str] = mapped_column(String(20))
|
|
name: Mapped[str] = mapped_column(String(40))
|
|
is_outdoor: Mapped[bool] = mapped_column(Boolean)
|
|
icon: Mapped[str] = mapped_column(String(30))
|
|
reason: Mapped[str] = mapped_column(String(60))
|
|
best_time: Mapped[str] = mapped_column(String(30))
|
|
sort_order: Mapped[int] = mapped_column(SmallInteger, default=0)
|
|
lat: Mapped[Optional[Decimal]] = mapped_column(Numeric(8, 5), nullable=True)
|
|
lon: Mapped[Optional[Decimal]] = mapped_column(Numeric(8, 5), nullable=True)
|
|
image_url: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
|
|
|
|
|
|
class Event(Base):
|
|
__tablename__ = "event"
|
|
|
|
event_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
source_id: Mapped[Optional[str]] = mapped_column(String(20), unique=True, nullable=True)
|
|
sido_code: Mapped[str] = mapped_column(String(2))
|
|
region_code: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
|
|
area: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
name: Mapped[str] = mapped_column(String(60))
|
|
place_name: Mapped[str] = mapped_column(String(60))
|
|
address: Mapped[Optional[str]] = mapped_column(String(120), nullable=True)
|
|
icon: Mapped[str] = mapped_column(String(30), default="fireworks")
|
|
start_date: Mapped[date] = mapped_column(Date)
|
|
end_date: Mapped[date] = mapped_column(Date)
|
|
is_confirmed: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
source_url: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
|
|
image_url: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
|
|
lat: Mapped[Optional[Decimal]] = mapped_column(Numeric(8, 5), nullable=True)
|
|
lon: Mapped[Optional[Decimal]] = mapped_column(Numeric(8, 5), nullable=True)
|
|
kind: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
|
|
|
|
class SolarTerm(Base):
|
|
__tablename__ = "solar_term"
|
|
|
|
term_date: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(10))
|
|
|
|
|
|
class SeasonWeek(Base):
|
|
__tablename__ = "season_week"
|
|
|
|
year: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
week: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
headline: Mapped[str] = mapped_column(String(60))
|
|
poem_lines: Mapped[list] = mapped_column(JSONB)
|
|
author: Mapped[str] = mapped_column(String(60))
|
|
|
|
|
|
class Article(Base):
|
|
__tablename__ = "article"
|
|
|
|
article_id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
code: Mapped[str] = mapped_column(String(40), unique=True)
|
|
category: Mapped[int] = mapped_column(SmallInteger)
|
|
title: Mapped[str] = mapped_column(String(80))
|
|
read_minutes: Mapped[int] = mapped_column(SmallInteger)
|
|
icon: Mapped[str] = mapped_column(String(30))
|
|
body: Mapped[list] = mapped_column(JSONB)
|
|
show_from: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
show_until: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
sort_order: Mapped[int] = mapped_column(SmallInteger, default=0)
|
|
image_url: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
|
image_credit: Mapped[Optional[str]] = mapped_column(String(60), nullable=True)
|
|
|
|
|
|
class Post(Base):
|
|
__tablename__ = "post"
|
|
|
|
post_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
feed_date: Mapped[date] = mapped_column(Date)
|
|
position: Mapped[int] = mapped_column(SmallInteger)
|
|
scope: Mapped[str] = mapped_column(String(2), default="00")
|
|
post_type: Mapped[int] = mapped_column(SmallInteger)
|
|
ref_type: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
ref_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
index_rank: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
|
like_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
comment_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
published_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
end_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
deleted: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
|
|
|
|
class CardSet(Base):
|
|
__tablename__ = "card_set"
|
|
|
|
card_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
template: Mapped[str] = mapped_column(String(20))
|
|
topic: Mapped[Optional[str]] = mapped_column(String(60), nullable=True)
|
|
title: Mapped[str] = mapped_column(String(80))
|
|
caption: Mapped[str] = mapped_column(Text, default="")
|
|
copy: Mapped[dict] = mapped_column(JSONB, default=dict)
|
|
status: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
post_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
published_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
ig_media_id: Mapped[Optional[str]] = mapped_column(String(40), nullable=True)
|
|
hashtags: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
|
|
|
|
class CardImage(Base):
|
|
__tablename__ = "card_image"
|
|
|
|
card_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("card_set.card_id", ondelete="CASCADE"), primary_key=True)
|
|
seq: Mapped[int] = mapped_column(SmallInteger, primary_key=True)
|
|
data: Mapped[bytes] = mapped_column(LargeBinary)
|
|
|
|
|
|
class Reel(Base):
|
|
__tablename__ = "reel"
|
|
|
|
reel_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
title: Mapped[str] = mapped_column(String(80))
|
|
caption: Mapped[str] = mapped_column(Text, default="")
|
|
hashtags: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
video: Mapped[bytes] = mapped_column(LargeBinary)
|
|
cover: Mapped[Optional[bytes]] = mapped_column(LargeBinary, nullable=True)
|
|
ig_media_id: Mapped[Optional[str]] = mapped_column(String(40), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
provider: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
login_id: Mapped[str] = mapped_column(String(64))
|
|
password: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
provider_uid: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
nickname: Mapped[str] = mapped_column(String(30))
|
|
character: Mapped[str] = mapped_column(String(20), default="rabbit")
|
|
color: Mapped[str] = mapped_column(String(20), default="orange")
|
|
mood: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
status: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
terms_agreed_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
token_version: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
points: Mapped[int] = mapped_column(Integer, default=0)
|
|
birth_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
|
birth_time: Mapped[Optional[time]] = mapped_column(Time, nullable=True)
|
|
birth_place: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
gender: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
deleted: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
|
|
|
|
class PostLike(Base):
|
|
__tablename__ = "post_like"
|
|
|
|
post_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class PostLikeAnon(Base):
|
|
__tablename__ = "post_like_anon"
|
|
|
|
post_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
ip_hash: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class PostSave(Base):
|
|
__tablename__ = "post_save"
|
|
|
|
post_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class Comment(Base):
|
|
__tablename__ = "comment"
|
|
|
|
comment_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
# 포스트 댓글은 post_id, 사람 글 댓글은 talk_id 하나만 채운다
|
|
post_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
talk_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
user_id: Mapped[Optional[uuid.UUID]] = mapped_column(UUID(as_uuid=True), nullable=True)
|
|
ip_hash: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
|
region_name: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
|
bot: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
|
|
body: Mapped[str] = mapped_column(String(60))
|
|
like_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
report_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
is_hidden: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
deleted: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
|
|
|
|
class CommentReport(Base):
|
|
__tablename__ = "comment_report"
|
|
|
|
comment_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
reason: Mapped[int] = mapped_column(SmallInteger)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class UserBlock(Base):
|
|
__tablename__ = "user_block"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
blocked_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class CommentLike(Base):
|
|
__tablename__ = "comment_like"
|
|
|
|
comment_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class CommentLikeAnon(Base):
|
|
__tablename__ = "comment_like_anon"
|
|
|
|
comment_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
ip_hash: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class MyGak(Base):
|
|
__tablename__ = "my_gak"
|
|
|
|
my_gak_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True))
|
|
name: Mapped[str] = mapped_column(String(12))
|
|
icon: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
|
|
rule: Mapped[dict] = mapped_column(JSONB)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class PointLog(Base):
|
|
__tablename__ = "point_log"
|
|
|
|
point_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True))
|
|
day: Mapped[date] = mapped_column(Date)
|
|
action: Mapped[str] = mapped_column(String(20))
|
|
ref: Mapped[str] = mapped_column(String(40), default="")
|
|
points: Mapped[int] = mapped_column(SmallInteger)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class FortuneDraw(Base):
|
|
__tablename__ = "fortune_draw"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
day: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
card_code: Mapped[str] = mapped_column(String(32))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class DayLog(Base):
|
|
__tablename__ = "day_log"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
day: Mapped[date] = mapped_column(Date, primary_key=True)
|
|
mood: Mapped[int] = mapped_column(SmallInteger)
|
|
went_out: Mapped[bool] = mapped_column(Boolean)
|
|
place_name: Mapped[Optional[str]] = mapped_column(String(40), nullable=True)
|
|
place_ref: Mapped[Optional[str]] = mapped_column(String(40), nullable=True)
|
|
card_hit: Mapped[Optional[bool]] = mapped_column(Boolean, nullable=True)
|
|
region_code: Mapped[str] = mapped_column(String(10))
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class Talk(Base):
|
|
__tablename__ = "talk"
|
|
|
|
talk_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True))
|
|
region_code: Mapped[str] = mapped_column(String(10))
|
|
body: Mapped[str] = mapped_column(String(100))
|
|
weather: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)
|
|
image: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
|
topic: Mapped[int] = mapped_column(SmallInteger, default=1)
|
|
like_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
comment_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
report_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
hidden: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
deleted: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
|
|
|
|
class TalkLike(Base):
|
|
__tablename__ = "talk_like"
|
|
|
|
talk_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class TalkLikeAnon(Base):
|
|
__tablename__ = "talk_like_anon"
|
|
|
|
talk_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
ip_hash: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class TalkReport(Base):
|
|
__tablename__ = "talk_report"
|
|
|
|
talk_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
reason: Mapped[int] = mapped_column(SmallInteger)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|