[refactor] postgres-init,solution: DB 구조 재편 — 스키마 해체 · 공용 콘텐츠 한 벌 · 마이그레이션 체계
도메인별 스키마(company·place·fact·local·site·job)를 걷어내고 public 한 벌로 폈다.
스키마 한정자가 붙은 순간부터 ORM·raw SQL·테스트 픽스처가 각자 그 이름을 들고 다녀야 했다.
- 공용 콘텐츠를 한 테이블로 되돌린다. spots·region_stories 를 따로 파 놓고 보니
같은 성격이 세 곳으로 갈라져 있었다 — `area_contents` 가 처음부터 content_type 으로
종류를 가르는 설계였고 그걸 쓰면 됐다. 관계(거리·숨김)만 `place_area_refs` 로 남긴다.
- migrations/ + scripts/migrate.py: `init.sql` 은 **DB 를 처음 만들 때만** 돈다. 파일에
컬럼을 더해도 이미 데이터가 든 DB 에는 반영되지 않는다 — 실제로 TourAPI 가 주변 정보를
받아 와도 저장할 곳이 없어 축제·맛집이 0건이었고, 화면에는 "그냥 안 나오는 것" 으로만 보였다.
DECISIONS.md 가 예고한 그대로다("운영 DB 가 생기는 순간 다시 필요해진다").
Alembic 을 쓰지 않는 이유는 스키마 정의가 이미 두 곳(ORM·init.sql)이라 세 번째를
더하면 어긋날 자리가 하나 더 생기기 때문이다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7bbeb068a8
commit
64ce467f21
189 files changed
+13374
-5023
No files matched your search
@@ -1,17 +1,18 @@
|
||||
import {useState} from 'react';
|
||||
import {Car, Check, Copy, Navigation} from 'lucide-react';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {kakaoDirectionsUrl, naverDirectionsUrl, osmEmbedUrl} from '@/lib/format';
|
||||
import {sectionName} from '@/lib/derive';
|
||||
import {kakaoDirectionsUrl, naverDirectionsUrl, osmEmbedUrl, tmapDirectionsUrl} from '@/lib/format';
|
||||
import {Section} from '@/lib/ui';
|
||||
|
||||
/**
|
||||
* 오시는 길.
|
||||
*
|
||||
* ★ 마크업은 목업(/s/stay 의 `<section id="location">`)에서 그대로 옮겼다.
|
||||
* 지도 7 : 주소·길찾기 5 의 가로 배치다. 지도를 위에 눕히면 주소가 접힌 화면 밖으로 밀린다.
|
||||
* ★ 길찾기 버튼 색은 각 서비스의 브랜드색을 그대로 쓴다(네이버 #03C75A · 카카오 #FEE500 ·
|
||||
* 티맵 #0064FF). 템플릿 색으로 칠하면 어느 앱으로 가는지 손님이 못 알아본다.
|
||||
* ★ 티맵은 앱 딥링크라 손가락 화면에서만 보인다(`only-touch`).
|
||||
* ★ 지도를 폭 전체에 눕히지 않는다. 16:9 지도가 1200px 폭을 차지하면 세로 675px 짜리
|
||||
* 빈 회색 판이 화면 하나를 통째로 먹고, 정작 주소와 길찾기 버튼은 그 아래로 밀렸다.
|
||||
* 넓은 화면에서는 지도(7) 옆에 주소·길찾기·소요시간(5)을 세운다.
|
||||
*
|
||||
* ★ 네이버 초록·카카오 노랑은 템플릿 색으로 바꾸지 않는다 — 그건 디자인이 아니라
|
||||
* 남의 서비스 식별색이다. 손님은 색으로 버튼을 찾는다.
|
||||
*/
|
||||
export function LocationSection() {
|
||||
const payload = useSite();
|
||||
@@ -25,7 +26,7 @@ export function LocationSection() {
|
||||
// 버튼은 검색으로 떨어진다(format.ts) — 틀린 핀을 찍느니 안 찍는다.
|
||||
const {latitude: lat, longitude: lng} = place;
|
||||
const hasGeo = lat != null && lng != null;
|
||||
const q = encodeURIComponent(place.name);
|
||||
const tmap = tmapDirectionsUrl(place.name, lat, lng);
|
||||
|
||||
const handleCopy = async () => {
|
||||
try {
|
||||
@@ -38,124 +39,134 @@ export function LocationSection() {
|
||||
};
|
||||
|
||||
return (
|
||||
<section
|
||||
<Section
|
||||
id="location"
|
||||
aria-labelledby="location-heading"
|
||||
className="border-line paper w-full border-b"
|
||||
style={{backgroundColor: 'var(--tpl-surface, #ffffff)', paddingBlock: 'var(--section-space)'}}
|
||||
title="오시는 길"
|
||||
lead="주소와 주요 거점까지의 이동 시간을 안내합니다."
|
||||
>
|
||||
<div className="shell">
|
||||
<div>
|
||||
<header className="mb-6 sm:mb-8">
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between sm:gap-6">
|
||||
<div className="min-w-0">
|
||||
<h2 id="location-heading" className="h2 flex items-center gap-2.5">
|
||||
<i aria-hidden="true" className="h-[1em] w-[3px] shrink-0 bg-current opacity-25" />
|
||||
<span className="min-w-0">{sectionName(payload, 'map', '오시는 길')}</span>
|
||||
</h2>
|
||||
<p className="text-muted measure mt-2 pl-[calc(3px+0.625rem)] text-[length:var(--fs-sm)]">
|
||||
주소와 주요 거점까지의 이동 시간을 안내합니다.
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-6 lg:grid-cols-12 lg:gap-8">
|
||||
{hasGeo && (
|
||||
<div className="border-line tpl-border overflow-hidden rounded-xl border lg:col-span-7">
|
||||
{/* ★ loading="lazy" — 지도는 접힌 화면 아래에 있는 경우가 많고, 첫 화면 속도를
|
||||
남의 서버 응답에 맡기지 않는다. title 은 스크린리더가 읽을 유일한 설명이다. */}
|
||||
<iframe
|
||||
title={`${place.name} 위치 지도`}
|
||||
src={osmEmbedUrl(lat, lng)}
|
||||
loading="lazy"
|
||||
referrerPolicy="no-referrer-when-downgrade"
|
||||
className="block aspect-4/3 w-full border-0 sm:aspect-video lg:aspect-auto lg:h-full lg:min-h-[24rem]"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={hasGeo ? 'lg:col-span-5' : 'lg:col-span-12'}>
|
||||
<div className="panel p-5 sm:p-6">
|
||||
<p className="label mb-2">주소</p>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* address 태그로 감싼다 — 기계가 "이게 이 업소의 주소"임을 안다. */}
|
||||
<address className="text-[length:var(--fs-lead)] font-bold not-italic">
|
||||
{address}
|
||||
</address>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCopy}
|
||||
title="주소 복사"
|
||||
className="border-line tpl-border inline-flex items-center gap-1 rounded-md border bg-current/8 px-2.5 py-1.5 text-[length:var(--fs-xs)] font-medium transition-opacity hover:opacity-70"
|
||||
>
|
||||
{copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
|
||||
<span>{copied ? '복사완료' : '복사'}</span>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 lg:grid-cols-12 lg:gap-8">
|
||||
{hasGeo && (
|
||||
<div className="border-line tpl-border overflow-hidden rounded-xl border lg:col-span-7">
|
||||
{/* ★ loading="lazy" — 지도는 접힌 화면 아래에 있는 경우가 많고, 첫 화면 속도를
|
||||
남의 서버 응답에 맡기지 않는다. title 은 스크린리더가 읽을 유일한 설명이다. */}
|
||||
<iframe
|
||||
title={`${place.name} 위치 지도`}
|
||||
src={osmEmbedUrl(lat, lng)}
|
||||
loading="lazy"
|
||||
referrerPolicy="no-referrer-when-downgrade"
|
||||
className="block aspect-4/3 w-full border-0 sm:aspect-video lg:aspect-auto lg:h-full lg:min-h-[24rem]"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={hasGeo ? 'lg:col-span-5' : 'lg:col-span-12'}>
|
||||
<div className="panel p-5 sm:p-6">
|
||||
<p className="label mb-2">주소</p>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* address 태그로 감싼다 — 기계가 "이게 이 업소의 주소"임을 안다. */}
|
||||
<address className="text-[length:var(--fs-lead)] font-bold not-italic">{address}</address>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCopy}
|
||||
title="주소 복사"
|
||||
className="border-line tpl-border inline-flex items-center gap-1 rounded-md border bg-current/8 px-2.5 py-1.5 text-[length:var(--fs-xs)] font-medium transition-opacity hover:opacity-70"
|
||||
>
|
||||
{copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
|
||||
<span>{copied ? '복사완료' : '복사'}</span>
|
||||
</button>
|
||||
</div>
|
||||
{place.phone && (
|
||||
<p className="text-muted mt-2 text-[length:var(--fs-sm)]">
|
||||
문의:{' '}
|
||||
<a href={`tel:${place.phone}`} className="underline-offset-2 hover:underline">
|
||||
{place.phone}
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-5 flex flex-wrap gap-2.5">
|
||||
<a
|
||||
href={naverDirectionsUrl(place.name, lat, lng)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#03C75A] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-3.5" aria-hidden="true" />
|
||||
<span>네이버 길찾기</span>
|
||||
{place.phone && (
|
||||
<p className="text-muted mt-2 text-[length:var(--fs-sm)]">
|
||||
문의:{' '}
|
||||
<a href={`tel:${place.phone}`} className="underline-offset-2 hover:underline">
|
||||
{place.phone}
|
||||
</a>
|
||||
<a
|
||||
href={kakaoDirectionsUrl(place.name, lat, lng)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#FEE500] px-4 text-[length:var(--fs-sm)] font-bold text-[#191600] transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-3.5" aria-hidden="true" />
|
||||
<span>카카오 길찾기</span>
|
||||
</a>
|
||||
{hasGeo && (
|
||||
<a
|
||||
href={`tmap://route?goalname=${q}&goalx=${lng}&goaly=${lat}&rGoName=${q}&rGoX=${lng}&rGoY=${lat}`}
|
||||
className="tap only-touch flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#0064FF] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-3.5" aria-hidden="true" />
|
||||
<span>티맵 길찾기</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{routes.length > 0 && (
|
||||
<div className="mt-6">
|
||||
<h3 className="mb-3 flex items-center gap-2 text-[length:var(--fs-sm)] font-bold">
|
||||
<Car className="size-4 opacity-60" aria-hidden="true" />
|
||||
<span>주요 거점 소요시간</span>
|
||||
</h3>
|
||||
<dl className="divide-line border-line divide-y border-t">
|
||||
{routes.map((route) => (
|
||||
<div
|
||||
key={route.destination}
|
||||
className="flex items-baseline justify-between gap-4 py-2.5 text-[length:var(--fs-sm)]"
|
||||
>
|
||||
<dt className="text-muted shrink-0">{route.destination}</dt>
|
||||
<dd className="text-right font-semibold">
|
||||
{[route.byCar, route.byTransit].filter(Boolean).join(' · ') || '—'}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/*
|
||||
★ 줄바꿈을 막고 자리가 모자라면 아래로 내린다 (2026-09-04, 사장님: "3안 버튼 깨짐")
|
||||
xl 에서 가로로 세웠는데, 본문 칸이 좁은 안(oasi 는 716px 고정)에서는
|
||||
"네이버 / 길찾기" 로 두 줄이 되고 화살표만 세로 가운데에 남아 깨져 보였다.
|
||||
글자는 안 자르고(nowrap), 대신 버튼이 통째로 다음 줄로 내려간다(wrap).
|
||||
*/}
|
||||
<div className="mt-5 flex flex-wrap gap-2.5">
|
||||
<a
|
||||
href={naverDirectionsUrl(place.name, lat, lng)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#03C75A] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-4" />
|
||||
<span>네이버 길찾기</span>
|
||||
</a>
|
||||
<a
|
||||
href={kakaoDirectionsUrl(place.name, lat, lng)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
className="tap flex flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#FEE500] px-4 text-[length:var(--fs-sm)] font-bold text-[#191600] transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-4" />
|
||||
<span>카카오 길찾기</span>
|
||||
</a>
|
||||
{/* 티맵은 앱 스킴뿐이라 터치 기기에서만 — PC 에서는 눌러도 아무 일이 없다. */}
|
||||
{tmap && (
|
||||
<a
|
||||
href={tmap}
|
||||
className="tap only-touch flex-1 basis-40 items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-[#0064FF] px-4 text-[length:var(--fs-sm)] font-bold text-white transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Navigation className="size-4" />
|
||||
<span>티맵 길찾기</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{routes.length > 0 && (
|
||||
<div className="mt-8">
|
||||
<h3 className="mb-3 flex items-center gap-2 text-[length:var(--fs-sm)] font-bold">
|
||||
<Car className="size-4 opacity-50" />
|
||||
<span>주요 거점 소요시간</span>
|
||||
</h3>
|
||||
|
||||
<div className="panel overflow-hidden">
|
||||
{/* 좁은 화면에서는 표를 가로로 민다 — 열을 접으면 값이 사라져 인용이 끊긴다. */}
|
||||
<div className="slider-viewport">
|
||||
<table className="w-full min-w-[34rem] text-left text-[length:var(--fs-sm)]">
|
||||
<caption className="sr-only">
|
||||
{payload.place.name}에서 주요 거점까지의 이동 시간
|
||||
</caption>
|
||||
<thead className="panel-sunken border-line border-b font-semibold">
|
||||
<tr>
|
||||
<th scope="col" className="p-4">목적지</th>
|
||||
<th scope="col" className="p-4">차량</th>
|
||||
<th scope="col" className="p-4">도보 / 대중교통</th>
|
||||
<th scope="col" className="p-4">거리</th>
|
||||
<th scope="col" className="hidden p-4 md:table-cell">비고</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-line divide-y">
|
||||
{routes.map((route) => (
|
||||
<tr key={route.destination}>
|
||||
<th scope="row" className="p-4 text-left font-bold">
|
||||
{route.destination}
|
||||
</th>
|
||||
<td className="p-4 font-semibold">{route.byCar ?? '—'}</td>
|
||||
<td className="p-4 opacity-70">{route.byTransit ?? '—'}</td>
|
||||
<td className="text-muted p-4 tabular-nums">{route.distanceText ?? '—'}</td>
|
||||
<td className="text-muted hidden p-4 md:table-cell">{route.note ?? ''}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user