Initial import
This commit is contained in:
4
etc/db/work-db/.env.example
Executable file
4
etc/db/work-db/.env.example
Executable file
@@ -0,0 +1,4 @@
|
||||
POSTGRES_DB=work_db
|
||||
POSTGRES_USER=work_user
|
||||
POSTGRES_PASSWORD=change-me
|
||||
POSTGRES_PORT=5432
|
||||
2
etc/db/work-db/.gitignore
vendored
Executable file
2
etc/db/work-db/.gitignore
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
postgres-data
|
||||
28
etc/db/work-db/README.md
Executable file
28
etc/db/work-db/README.md
Executable file
@@ -0,0 +1,28 @@
|
||||
# Work DB
|
||||
|
||||
로컬 개발용 PostgreSQL 컨테이너입니다.
|
||||
|
||||
## 실행
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
docker compose logs -f postgres
|
||||
```
|
||||
|
||||
## 중지
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
```
|
||||
|
||||
## 기본 접속 정보
|
||||
|
||||
- Host: `localhost`
|
||||
- Port: `.env`의 `POSTGRES_PORT`
|
||||
- Database: `.env`의 `POSTGRES_DB`
|
||||
- User: `.env`의 `POSTGRES_USER`
|
||||
- Password: `.env`의 `POSTGRES_PASSWORD`
|
||||
|
||||
## work-server 연동
|
||||
|
||||
`etc/servers/work-server/.env`의 DB 설정과 맞춰서 사용합니다.
|
||||
41
etc/db/work-db/docker-compose.yml
Executable file
41
etc/db/work-db/docker-compose.yml
Executable file
@@ -0,0 +1,41 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: work-db
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "200m"
|
||||
max-file: "2"
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- path: ./.env.example
|
||||
required: false
|
||||
- path: ./.env
|
||||
required: false
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
ports:
|
||||
- '${POSTGRES_PORT:-5432}:5432'
|
||||
volumes:
|
||||
- work-db-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- work-backend
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
'CMD-SHELL',
|
||||
'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB'
|
||||
]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
volumes:
|
||||
work-db-data:
|
||||
|
||||
networks:
|
||||
work-backend:
|
||||
name: work-backend
|
||||
12
etc/db/work-db/sql/board-posts.sql
Executable file
12
etc/db/work-db/sql/board-posts.sql
Executable file
@@ -0,0 +1,12 @@
|
||||
create table if not exists board_posts (
|
||||
id serial primary key,
|
||||
title varchar(200) not null,
|
||||
content text not null,
|
||||
automation_plan_item_id integer null,
|
||||
automation_received_at timestamptz null,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists idx_board_posts_updated_at
|
||||
on board_posts (updated_at desc);
|
||||
16
etc/db/work-db/sql/notification-messages.sql
Executable file
16
etc/db/work-db/sql/notification-messages.sql
Executable file
@@ -0,0 +1,16 @@
|
||||
create table if not exists notification_messages (
|
||||
id serial primary key,
|
||||
title varchar(200) not null,
|
||||
body text not null,
|
||||
category varchar(60) not null default 'general',
|
||||
source varchar(80) not null default 'system',
|
||||
priority varchar(20) not null default 'normal',
|
||||
is_read boolean not null default false,
|
||||
read_at timestamptz null,
|
||||
metadata_json jsonb not null default '{}'::jsonb,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists idx_notification_messages_unread_created_at
|
||||
on notification_messages (is_read, created_at desc, id desc);
|
||||
34
etc/db/work-db/sql/visitor-history.sql
Executable file
34
etc/db/work-db/sql/visitor-history.sql
Executable file
@@ -0,0 +1,34 @@
|
||||
-- 방문자 마스터 테이블: clientId 단위 집계 정보 보관
|
||||
create table if not exists visitor_clients (
|
||||
id serial primary key,
|
||||
client_id varchar(120) not null unique,
|
||||
nickname varchar(80) not null,
|
||||
first_visited_at timestamptz not null default now(),
|
||||
last_visited_at timestamptz not null default now(),
|
||||
visit_count integer not null default 1,
|
||||
last_visited_url varchar(2000),
|
||||
last_user_agent varchar(1000),
|
||||
last_ip varchar(120),
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists idx_visitor_clients_last_visited_at
|
||||
on visitor_clients (last_visited_at desc);
|
||||
|
||||
-- 방문 상세 이력 테이블: 중복 방문도 모두 적재
|
||||
create table if not exists visitor_visit_histories (
|
||||
id serial primary key,
|
||||
client_id varchar(120) not null,
|
||||
visited_at timestamptz not null default now(),
|
||||
url varchar(2000) not null,
|
||||
event_type varchar(80) not null default 'page_view',
|
||||
user_agent varchar(1000),
|
||||
ip varchar(120)
|
||||
);
|
||||
|
||||
create index if not exists idx_visitor_visit_histories_client_id
|
||||
on visitor_visit_histories (client_id);
|
||||
|
||||
create index if not exists idx_visitor_visit_histories_visited_at
|
||||
on visitor_visit_histories (visited_at desc);
|
||||
Reference in New Issue
Block a user