삽질하다 도저히 문제 파악이 안돼서 opcUaManager로 분리 테스트 중
This commit is contained in:
23
opcUaManager/init_db.sql
Normal file
23
opcUaManager/init_db.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- ============================================================
|
||||
-- OPC UA Manager — PostgreSQL 초기화 스크립트
|
||||
-- 실행: psql -U postgres -d opcdb -f init_db.sql
|
||||
-- ============================================================
|
||||
|
||||
-- 데이터베이스 생성 (psql 에서 직접 실행 시)
|
||||
-- CREATE DATABASE opcdb;
|
||||
|
||||
-- opc_history 테이블
|
||||
CREATE TABLE IF NOT EXISTS opc_history (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
tag_name TEXT NOT NULL,
|
||||
tag_value DOUBLE PRECISION NOT NULL,
|
||||
status_code TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- 인덱스 (태그명 + 시간 기준 조회 최적화)
|
||||
CREATE INDEX IF NOT EXISTS idx_opc_history_tag_name ON opc_history (tag_name);
|
||||
CREATE INDEX IF NOT EXISTS idx_opc_history_created_at ON opc_history (created_at DESC);
|
||||
|
||||
-- 확인
|
||||
SELECT 'opc_history 테이블 준비 완료' AS result;
|
||||
Reference in New Issue
Block a user