Vasily.onl 8121ce0430 Update database schema and configuration for Crypto Trading Bot Platform
- Added new SQLAlchemy models in `database/models.py` for market data, trades, bots, signals, and performance tracking.
- Updated `docker-compose.yml` to use TimescaleDB for PostgreSQL and configured shared preload libraries.
- Created new schema files: `schema.sql` for the complete database setup and `schema_clean.sql` for a simplified version without hypertables.
- Updated documentation in `setup.md` to reflect changes in database initialization and service setup.
2025-05-30 17:45:57 +08:00

27 lines
784 B
PL/PgSQL

-- Initial database setup for Crypto Trading Bot Dashboard
-- This script runs when PostgreSQL container starts for the first time
-- Create extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Set timezone
SET timezone = 'UTC';
-- Create initial user with appropriate permissions (if not exists)
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'dashboard') THEN
CREATE ROLE dashboard WITH LOGIN PASSWORD 'dashboard123';
END IF;
END
$$;
-- Grant permissions
GRANT ALL PRIVILEGES ON DATABASE dashboard TO dashboard;
GRANT ALL ON SCHEMA public TO dashboard;
-- Create initial comment
COMMENT ON DATABASE dashboard IS 'Crypto Trading Bot Dashboard Database';
-- Execute the main schema file
\i /docker-entrypoint-initdb.d/schema.sql