Files
amneziavpnphp/migrations
infosave2007 809b0ca63d feat(migrations): Add WARP auto-integration with redsocks and iptables
- Implemented migration 067 to set up Cloudflare WARP with automatic routing for VPN client TCP traffic through a redsocks proxy.
- Included installation scripts for WARP and redsocks, along with iptables rules for traffic redirection.
- Added detection for X-Ray and patching of its outbound configuration.
- Created uninstall scripts to clean up configurations and remove installed packages.

fix(migrations): Enhance WARP install script for heredoc compatibility

- Implemented migration 068 to fix nested heredoc conflicts and streamline the WARP installation script for panel compatibility.
- Removed duplicate `set -eo pipefail` and adjusted formatting for better readability.

feat(migrations): Auto-detect AIVPN subnet for routing in WARP setup

- Implemented migration 069 to enhance the WARP installation script by adding detection for AIVPN subnets alongside existing AWG container detection.
- Updated routing logic to handle both container IPs and host-level VPN subnets.
- Ensured proper configuration of iptables for seamless traffic routing through the WARP proxy.
2026-04-25 10:40:21 +03:00
..

Database Migrations

This directory contains SQL migration files that are automatically executed when the database container is first initialized.

Execution Order

Migration files are executed in alphabetical order by MySQL's Docker entrypoint. Files are numbered to ensure correct execution sequence:

  1. 001_init.sql - Main database schema and tables
  2. 002_translations_ru.sql - Russian translations
  3. 003_translations_es.sql - Spanish translations
  4. 004_translations_de.sql - German translations
  5. 005_translations_fr.sql - French translations
  6. 006_translations_zh.sql - Chinese translations

Adding New Migrations

When creating new migration files:

  1. Use numerical prefix (e.g., 007_add_feature.sql)
  2. Ensure the number is higher than existing migrations
  3. Use descriptive names
  4. Always use ON DUPLICATE KEY UPDATE for INSERT statements to make migrations idempotent

Manual Execution

To manually run migrations in an existing database:

# Single migration
docker compose exec db mysql -uroot -prootpassword amnezia_panel < migrations/001_init.sql

# All migrations in order
for file in migrations/*.sql; do
  echo "Executing $file..."
  docker compose exec -T db mysql -uroot -prootpassword amnezia_panel < "$file"
done

Regenerating Translation Migrations

To regenerate translation migrations from the current database:

# Export translations for a specific language
docker compose exec -T db mysql -uroot -prootpassword amnezia_panel \
  --default-character-set=utf8mb4 \
  -e "SELECT CONCAT('(''', language_code, ''', ''', translation_key, ''', ''', 
      REPLACE(translation_value, '''', ''''''), '''),') 
      FROM translations WHERE language_code = 'ru' ORDER BY translation_key;" \
  | grep -v "CONCAT" > /tmp/translations_ru.sql

# Then wrap with INSERT statement and ON DUPLICATE KEY UPDATE