Добавление реплик и балансировщик миграции отдельно

This commit is contained in:
Dmitry
2026-10-26 20:58:48 +03:00
parent 0ab3a341aa
commit 189f880651
66 changed files with 2851 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
spring:
jackson:
property-naming-strategy: SNAKE_CASE
deserialization:
fail-on-unknown-properties: true
lifecycle:
timeout-per-shutdown-cycle=10s:
spring:
datasource:
url: ${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5433/lido_db}
username: ${SPRING_DATASOURCE_USERNAME:user}
password: ${SPRING_DATASOURCE_PASSWORD:user}
hikari:
maximum-pool-size: 10
minimum-idle: 2
connection-timeout: 3000
idle-timeout: 600000
max-lifetime: 1800000
validation-timeout: 2000
jpa:
open-in-view: false
hibernate:
ddl-auto: validate
properties:
hibernate:
jdbc:
time_zone: UTC
flyway:
enabled: ${FLYWAY_ENABLED:false}
locations: classpath:db/migration
redis:
host: ${SPRING_DATA_REDIS_HOST:localhost}
port: ${SPRING_DATA_REDIS_PORT:6379}
timeout: 300ms
connect-timeout: 300ms
lettuce:
shutdown-timeout: 100ms
repositories:
enabled: false
server:
port: ${SERVER_PORT:8080}
app:
session-ttl-seconds: ${SESSION_TTL_SECONDS:604800}
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} [req_id: %X{X-Request-Id}] - %msg%n"
level:
root=INFO:
org:
springframework:
web=DEBUG:
web:
filter:
CommonsRequestLoggingFilter=DEBUG:
:servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: DEBUG
server:
shutdown=graceful:
management:
endpoints:
web:
exposure:
include=health:
health:
show-details=always:
@@ -0,0 +1,35 @@
CREATE TABLE users (
id UUID PRIMARY KEY,
username VARCHAR(64) NOT NULL,
display_name VARCHAR(128) NOT NULL,
password VARCHAR(255),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT uq_users_username UNIQUE (username)
);
CREATE TABLE chats (
id UUID PRIMARY KEY,
title VARCHAR(32) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE chat_members (
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
joined_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (chat_id, user_id)
);
CREATE INDEX idx_chat_members_user ON chat_members (user_id);
CREATE TABLE messages (
id UUID PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
sender_id UUID NOT NULL REFERENCES users(id),
text TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT chk_messages_text_nonempty CHECK (char_length(trim(text)) > 0)
);
CREATE INDEX idx_messages_chat_created_id
ON messages (chat_id, created_at DESC, id DESC);
@@ -0,0 +1,12 @@
CREATE TABLE sessions (
id UUID PRIMARY KEY,
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token VARCHAR(64) NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
revoked_at TIMESTAMPTZ NULL,
CONSTRAINT uq_sessions_token_hash UNIQUE (token)
);
CREATE INDEX idx_sessions_user_id ON sessions (user_id);
CREATE INDEX idx_sessions_expires_at ON sessions (expires_at);
@@ -0,0 +1,4 @@
DROP INDEX IF EXISTS idx_messages_chat_created_id;
CREATE INDEX idx_messages_chat_created_id
ON messages (chat_id, created_at ASC, id ASC);
@@ -0,0 +1,2 @@
ALTER TABLE chats
ALTER COLUMN title TYPE VARCHAR(100);