Add live SQL import for local and staging sync

This commit is contained in:
Dwindi Ramadhana
2026-02-07 13:37:02 +07:00
parent 844ad4901b
commit 3c8f061819
5 changed files with 652 additions and 0 deletions

74
current-local-db.md Normal file
View File

@@ -0,0 +1,74 @@
# Current Local Database (SQLite)
This describes what exists **right now** in the rebuild app (`app/database/database.sqlite`).
## Local DB engine
- SQLite (file: `app/database/database.sqlite`)
## Tables present
Framework defaults:
- `cache`
- `cache_locks`
- `failed_jobs`
- `job_batches`
- `jobs`
- `migrations`
- `password_reset_tokens`
- `sessions`
- `users`
Dewemoji core tables:
- `licenses`
- `license_activations`
- `usage_logs`
## Current row counts (local)
- `emojis`: 2131
- `emoji_keywords`: 13420
- `emoji_aliases`: 0
- `emoji_shortcodes`: 0
- `licenses`: 7
- `license_activations`: 1
- `usage_logs`: 88
- `ai_guard_logs`: 54
- `ai_judgments`: 0
- `ai_lang_cache`: 6
- `ai_provider_usage`: 4
- `legacy_users`: 0
- `legacy_sessions`: 0
## What is *not* in local DB yet (from live SQL)
From `dewemoji-live-backend/dewemojiAPI_DB.sql`, these tables exist in live but are **still empty locally**:
- `emoji_aliases`
- `emoji_shortcodes`
- `ai_judgments`
- `legacy_users` (live users)
- `legacy_sessions` (live sessions)
## Why emojis still work locally
The rebuild app currently reads emojis from a **JSON dataset** (not DB):
- `app/data/emojis.json`
Thats why the UI works even though emoji tables arent present yet.
## Next step (if you want to migrate live SQL)
Migrations + importer are now in place. To sync everything locally (SQLite), run:
```bash
cd /Users/dwindown/Developments/dewemoji/app
php artisan migrate
php artisan dewemoji:import-live-sql /Users/dwindown/Developments/dewemoji-live-backend/dewemojiAPI_DB.sql --truncate
```
Notes:
- Live `users` + `sessions` go into `legacy_users` + `legacy_sessions` (so Laravel auth/session tables stay safe).
- Licenses/activations/usage_logs are mapped into the current tables for parity.
Just tell me which subset to migrate first.