[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
@@ -0,0 +1,240 @@
|
||||
import type {ChannelLink} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {
|
||||
bookingLabel,
|
||||
bookingLinks,
|
||||
sectionName,
|
||||
unitSpec,
|
||||
unitViews,
|
||||
type UnitView,
|
||||
} from '@/lib/derive';
|
||||
import {GRAIN, SectionHead} from './SectionHead';
|
||||
|
||||
/**
|
||||
* 편집(잡지)형 객실 — 한 객실이 한 판이다.
|
||||
*
|
||||
* ★ 카드로 감싸지 않는다. 카드 격자는 '고르는 화면'이고, 잡지의 판은 '보여 주는 화면'이다.
|
||||
* 판마다 배경을 밝은 면 ↔ 어두운 면으로 교차해 넘기는 리듬을 만든다.
|
||||
* ★ `lib/ui/Section` 을 쓰지 않고 <section> 을 직접 그린다 — 판마다 배경이 갈려야 하는데
|
||||
* Section 은 섹션 하나에 바탕 하나다.
|
||||
* ★ 사진은 두 장을 위아래로 어긋나게 걸되, 세 번째부터는 아래 접지(contact sheet)로 남긴다.
|
||||
* 장식을 위해 사진을 버리면 그 alt 문장이 HTML 에서 사라진다 — 인용될 자리가 준다.
|
||||
*/
|
||||
export function Rooms() {
|
||||
const payload = useSite();
|
||||
const units = unitViews(payload);
|
||||
const spec = unitSpec(payload);
|
||||
const booking = bookingLinks(payload)[0];
|
||||
|
||||
if (units.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section
|
||||
id="units"
|
||||
aria-labelledby="units-heading"
|
||||
className="border-line w-full border-b"
|
||||
style={{
|
||||
backgroundColor: 'var(--tpl-surface)',
|
||||
backgroundImage: GRAIN,
|
||||
paddingBlock: 'var(--section-space)',
|
||||
}}
|
||||
>
|
||||
<div className="shell">
|
||||
{/* 섹션 id 는 업종마다 다르다(rooms · menu · programs) — spec.path 가 그 id 다. */}
|
||||
<SectionHead
|
||||
id="units"
|
||||
title={sectionName(payload, spec.path, `${spec.label} ${units.length}개 안내`)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{units.map((unit, order) => (
|
||||
<UnitSpread
|
||||
key={unit.unitId}
|
||||
unit={unit}
|
||||
no={String(order + 1).padStart(2, '0')}
|
||||
/* 홀수 번째 판을 어두운 면으로. 넘길 때마다 바탕이 뒤집힌다. */
|
||||
dark={order % 2 === 1}
|
||||
booking={booking}
|
||||
phone={payload.place.phone}
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function UnitSpread({
|
||||
unit,
|
||||
no,
|
||||
dark,
|
||||
booking,
|
||||
phone,
|
||||
}: {
|
||||
unit: UnitView;
|
||||
no: string;
|
||||
dark: boolean;
|
||||
booking?: ChannelLink;
|
||||
phone?: string;
|
||||
}) {
|
||||
return (
|
||||
<article
|
||||
className="w-full"
|
||||
style={
|
||||
dark
|
||||
? {backgroundColor: 'var(--tpl-inverse)', color: 'var(--tpl-bg)', backgroundImage: GRAIN}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{/*
|
||||
★ 가로 홈(gap-x-10)은 xl 부터다. 390px 에서 12칸 격자에 40px 홈을 주면
|
||||
홈만 440px 이라 컨테이너(347px)를 넘고, 페이지 전체가 77px 가로로 밀린다(실측).
|
||||
좁은 화면에서는 어차피 전부 col-span-12 라 홈이 할 일이 없다.
|
||||
*/}
|
||||
<div className="shell grid grid-cols-12 gap-y-6 py-10 xl:gap-x-10 xl:py-16">
|
||||
{/*
|
||||
왼쪽 절반 — 번호 · 이름 · 스펙. 읽는 값은 전부 종이 위에 있다.
|
||||
★ pr-8 은 장식이 아니다. 오른쪽 사진이 격자의 홈을 통째로 먹으므로(-ml-10)
|
||||
이 여백이 없으면 스펙 표의 값이 사진 모서리에 붙는다(실측: 간격 0px).
|
||||
*/}
|
||||
<div className="col-span-12 xl:col-span-5 xl:pr-8">
|
||||
<div className="relative">
|
||||
<span
|
||||
aria-hidden
|
||||
className="serif pointer-events-none absolute -top-1 left-0 select-none leading-none tabular-nums"
|
||||
style={{fontSize: 'clamp(3rem, 8vw, 6rem)', fontWeight: 800, opacity: 0.1}}
|
||||
>
|
||||
{no}
|
||||
</span>
|
||||
<h3
|
||||
className="serif relative pt-7 xl:pt-12"
|
||||
style={{
|
||||
fontSize: 'clamp(1.5rem, 3vw, 2.25rem)',
|
||||
fontWeight: 800,
|
||||
lineHeight: 1.1,
|
||||
letterSpacing: '-0.02em',
|
||||
}}
|
||||
>
|
||||
{unit.name}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
{unit.intro && (
|
||||
<p className="measure mt-4 font-serif text-[length:var(--fs-body)] leading-relaxed opacity-85">
|
||||
{unit.intro}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/*
|
||||
★ 요금은 한 값이 아니라 비교하는 값이다. 주중 하나만 적어 두면 손님은
|
||||
주말이 얼마인지 모른 채 전화를 걸거나 떠난다. 안 채워진 칸은 '문의' 로 온다.
|
||||
*/}
|
||||
|
||||
{/* 요금은 객실 정보에서 내지 않는다 — 사유는 sections/UnitsSection.tsx 의 같은 자리 주석. */}
|
||||
|
||||
{unit.rows.length > 0 && (
|
||||
<dl className="border-line mt-6 border-t">
|
||||
{unit.rows.map((row) => (
|
||||
<div
|
||||
key={row.label}
|
||||
className="border-line flex items-baseline justify-between gap-6 border-b py-2.5 text-[length:var(--fs-sm)]"
|
||||
>
|
||||
<dt className="text-muted shrink-0">{row.label}</dt>
|
||||
<dd className="text-right font-semibold">{row.value}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
)}
|
||||
|
||||
{(booking || phone) && (
|
||||
<div className="mt-6 flex flex-wrap items-center gap-x-6 gap-y-1 text-[length:var(--fs-sm)] font-bold">
|
||||
{booking && (
|
||||
<a
|
||||
href={booking.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="tap inline-flex items-center underline underline-offset-4"
|
||||
>
|
||||
{bookingLabel(booking)} 예약
|
||||
</a>
|
||||
)}
|
||||
{phone && (
|
||||
<a
|
||||
href={`tel:${phone}`}
|
||||
className="tap inline-flex items-center underline underline-offset-4"
|
||||
>
|
||||
{phone}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/*
|
||||
오른쪽 절반 — 사진 두 장을 어긋나게.
|
||||
★ -ml-10 이 격자의 홈(gap-x-10)을 그대로 먹는다. 글이 있는 칸까지 넘기지는 않는다 —
|
||||
겹침이 읽기를 방해하면 그건 장식이 아니라 고장이다.
|
||||
★ 음수 여백은 xl 부터다. 390px 에서는 두 장이 그냥 위아래로 선다.
|
||||
*/}
|
||||
<div className="col-span-12 xl:col-span-7 xl:-ml-10">
|
||||
{/*
|
||||
★ 폭을 64%/50% 로 잡은 건 취향이 아니라 균형이다. 82% 로 뒀더니 오른쪽 칸이
|
||||
1120px 이 되어 왼쪽 글 아래로 600px 짜리 빈 판이 생겼다(실측) —
|
||||
어두운 판에서는 그 빈자리가 통째로 검은 구멍으로 보인다.
|
||||
*/}
|
||||
{unit.images[0] && (
|
||||
<figure className="w-full xl:w-[64%]">
|
||||
<img
|
||||
src={unit.images[0].url}
|
||||
alt={unit.images[0].alt}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
width={unit.images[0].width}
|
||||
height={unit.images[0].height}
|
||||
className="w-full object-cover"
|
||||
style={{aspectRatio: '4 / 5'}}
|
||||
/>
|
||||
</figure>
|
||||
)}
|
||||
|
||||
{unit.images[1] && (
|
||||
<figure className="mt-3 w-full xl:-mt-24 xl:ml-auto xl:w-[50%]">
|
||||
<img
|
||||
src={unit.images[1].url}
|
||||
alt={unit.images[1].alt}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
width={unit.images[1].width}
|
||||
height={unit.images[1].height}
|
||||
className="w-full object-cover"
|
||||
style={{aspectRatio: '4 / 3'}}
|
||||
/>
|
||||
</figure>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/*
|
||||
나머지 사진 — 판 아래를 가로지르는 접지(contact sheet).
|
||||
★ 작게라도 남겨야 alt 가 HTML 에 남는다. 장식 때문에 사진을 버리면
|
||||
그 문장이 인용될 자리도 같이 사라진다.
|
||||
*/}
|
||||
{unit.images.length > 2 && (
|
||||
<ul className="col-span-12 grid grid-cols-3 gap-2 xl:grid-cols-6">
|
||||
{unit.images.slice(2).map((image) => (
|
||||
<li key={image.mediaId}>
|
||||
<img
|
||||
src={image.url}
|
||||
alt={image.alt}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
width={image.width}
|
||||
height={image.height}
|
||||
className="w-full object-cover"
|
||||
style={{aspectRatio: '3 / 2'}}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user