mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-08-29 05:52:08 -04:00
e4996ade03
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. Probe for the `user` table (schema marker)
3. If missing, fork-exec `ppanel-migrate up` to bring schema to v2131
4. Create admin if not present
5. Continue with redis/queue/scheduler
Verified:
- Empty DB → ppanel-migrate applies all 39 migrations in ~0.4s, admin created
- Go server's ppanel_go DB → schema detected, migrate skipped, clean start
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
(Rust uses 16-byte salt; Go's 8-byte salt fits in 100 but Rust's doesn't)
- Rewrite src/migration.rs:
* Remove sqlx::migrate!, run_migrations()
* Add ensure_schema(db, cfg): probe + invoke ppanel-migrate subprocess
- 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>
0 lines
0 B
SQL
0 lines
0 B
SQL
The file is empty.