feat(架构): 完善基础架构设计
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
-- This script runs when PostgreSQL container starts for the first time
|
||||
|
||||
-- Create development database if it doesn't exist
|
||||
CREATE DATABASE tyapi_dev;
|
||||
-- Note: tyapi_dev is already created by POSTGRES_DB environment variable
|
||||
|
||||
-- Create test database for running tests
|
||||
CREATE DATABASE tyapi_test;
|
||||
-- Note: Skip database creation in init script, handle in application if needed
|
||||
|
||||
-- Create production database (for reference)
|
||||
-- CREATE DATABASE tyapi_prod;
|
||||
@@ -30,25 +30,11 @@ CREATE SCHEMA IF NOT EXISTS metrics;
|
||||
-- Set search path
|
||||
SET search_path TO public, logs, metrics;
|
||||
|
||||
-- Connect to test database and setup extensions
|
||||
\c tyapi_test;
|
||||
-- Test database setup will be handled by application migrations
|
||||
-- when needed, since we don't create it in this init script
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS "pg_trgm";
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS "btree_gin";
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS public;
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS logs;
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS metrics;
|
||||
|
||||
SET search_path TO public, logs, metrics;
|
||||
|
||||
-- Switch back to development database
|
||||
\c tyapi_dev;
|
||||
-- Continue with development database setup
|
||||
-- (already connected to tyapi_dev)
|
||||
|
||||
-- Create application-specific roles (optional)
|
||||
-- CREATE ROLE tyapi_app WITH LOGIN PASSWORD 'app_password';
|
||||
@@ -63,9 +49,7 @@ SET search_path TO public, logs, metrics;
|
||||
-- This will be replaced by proper migrations in the application
|
||||
|
||||
-- Log the initialization
|
||||
INSERT INTO
|
||||
pg_stat_statements_info (dealloc)
|
||||
VALUES (0) ON CONFLICT DO NOTHING;
|
||||
-- Note: pg_stat_statements extension may not be available, skip this insert
|
||||
|
||||
-- Create a simple health check function
|
||||
CREATE OR REPLACE FUNCTION health_check()
|
||||
|
||||
Reference in New Issue
Block a user