12 Commits

Author SHA1 Message Date
Ember Moth aa71d56154 feat(migration) 2026-07-07 16:33:17 +08:00
Ember Moth 953a9e5409 feat(migration): replace sqlx::migrate with standalone Go migrate tool
Schema is now managed by a separate Go CLI at tools/migrate/, which embeds
the SQL files copied from server/initialize/migrate/database/ and tracks
state in the shared schema_migrations table. Rust no longer owns migrations
at startup.

Rust startup:
  1. Connect to DB
  2. ALWAYS invoke `ppanel-migrate up` (idempotent — no-op if already at latest)
  3. Create admin if not present
  4. Continue with redis/queue/scheduler

Changes:
  - Add tools/migrate/ — Go module wrapping golang-migrate
    * migrate/migrate.go: Migrate() + RunUp() (RunUp bypasses the iofs vs
      os.ErrNotExist sentinel mismatch that breaks Up() on already-migrated DBs)
    * migrate/sql/{postgres,mysql}/: SQL files copied from server
    * cmd/migrate/main.go: CLI (up/down/version/force/drop)
  - Widen password column from varchar(100) → varchar(255) in
    00001_init_schema.up.sql to fit Rust's 112-char PBKDF2 hash
  - Rewrite src/migration.rs:
    * Remove sqlx::migrate!, run_migrations(), schema_present()
    * Add ensure_schema(cfg): unconditionally invokes ppanel-migrate up
  - Fix src/db.rs::build_dsn: previously used cfg.config verbatim even when
    the default config string was for the wrong dialect (PG got MySQL's
    charset=utf8mb4 string and crashed on connect)
  - Delete old migrations/{postgres,mysql}/ (no longer used)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-06 11:25:52 +08:00
Ember Moth 0305d058c4 Update README.md 2026-07-05 22:37:44 +08:00
Ember Moth 5de9508963 fix bugs 2026-07-05 22:35:53 +08:00
Ember Moth 4ffdc89421 feat: README, config.example, turnstile integration, exchange rate, auth utils refactor 2026-07-05 21:15:17 +08:00
Ember Moth 25d190b90e update 2026-07-05 20:47:34 +08:00
Ember Moth 4f74e14fba add mysql2postgres 2026-07-05 20:45:27 +08:00
Ember Moth 5d0b790aa1 add mysql2postgres 2026-07-05 20:43:52 +08:00
Ember Moth 67bfc9bd72 add MySQL + PG down.sql 2026-07-05 20:36:25 +08:00
Ember Moth 7b3a94308f Add OTel 2026-07-05 20:33:59 +08:00
Ember Moth 29f022abe9 Inaitial 2026-07-05 20:28:19 +08:00
Ember Moth 2744c70c5c Initial 2026-07-05 20:27:58 +08:00