# ─────────────────────────────────────────────────────────────────────────────
# H2 / development profile.
# Activate with: --spring.profiles.active=h2
# ─────────────────────────────────────────────────────────────────────────────
spring:
  jpa:
    show-sql: true
    # Flyway owns DDL. Disable Hibernate validation in H2 because H2 reports
    # some MySQL-compatible legacy column types differently from MySQL/Hibernate.
    hibernate:
      ddl-auto: none
    # H2 uses the same SQL dialect as MySQL in MySQL compatibility mode

  # H2 console — enabled in dev ONLY.
  # Access restricted to ROLE_ADMIN via Spring Security (see WebSecurityConfig).
  # web-allow-others=false prevents remote access; rely on security for protection-in-depth.
  h2:
    console:
      path: /h2-console
      # Default OFF — enable explicitly at startup: --spring.h2.console.enabled=true
      enabled: false
      settings:
        web-allow-others: false

  datasource:
    # H2 2.x reserves USER/VALUE; keep them usable for the legacy schema names.
    url: jdbc:h2:~/testjiscuss;MODE=MySQL;NON_KEYWORDS=VALUE,USER
    username: sa
    password:
    driver-class-name: org.h2.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      min-idle: 1
      initial-size: 2
      max-active: 5
      max-wait: 3000
      validation-query: SELECT 1
      filter:
        stat:
          enabled: true
          db-type: h2
          log-slow-sql: true
          slow-sql-millis: 1000
      web-stat-filter:
        enabled: true
        exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
      stat-view-servlet:
        enabled: true
        url-pattern: /druid/*
        # Druid UI gated by Spring Security ROLE_ADMIN; built-in basic auth disabled
        reset-enable: false
        allow: 127.0.0.1

  # Flyway: run V1 + V2 migrations on H2 in-memory DB on startup
  flyway:
    locations: classpath:db/migration
    url: ${spring.datasource.url}
    user: ${spring.datasource.username}
    password: ${spring.datasource.password}

# Override default port for dev profile
server:
  port: 80
