# think.greaterchiangmai.com Two Laravel 10 apps sharing one MySQL database (`greaterc_db2024`): - `think.greaterchiangmai.com/` — public site - `think-backend.greaterchiangmai.com/` — CMS (`/login`) - `upload-large-file/` — standalone S3 multipart upload helper (Node) ## Local development Requires [Nix](https://nixos.org) with flakes. ```sh nix run # installs vendors on first run, starts MariaDB, serves both apps; Ctrl-C stops all ``` - site: http://127.0.0.1:8000 - CMS: http://127.0.0.1:8001 ### Database The schema is owned by the CMS: `think-backend.greaterchiangmai.com/database/migrations/` (10 tables; no `category` table — `category_id` 1/2 is hardcoded). `dev db start` runs `artisan migrate` there on every start, so a fresh checkout serves empty pages with no 500s. `2025_11_03_000000_create_content_tables` is a baseline that reproduces the production tables byte-for-byte (verified by diffing `mariadb-dump --no-data` against the prod export); its creates are guarded with `Schema::hasTable`, so running `migrate` on production only records it. Add new migrations in the backend for any schema change; the site app has none. To work with real content, load a production dump (drops and recreates the local DB): ```sh nix run . -- db import .dev/greaterc_db2024.sql # phpMyAdmin export, kept out of git nix run . -- db reset # back to empty schema ``` `nix run . -- ` forwards to the `dev` script; `nix develop` drops you into a shell with `dev`, `php`, `composer`, `mariadb`, `node` on PATH (direnv: `.envrc` → `use flake`). Other commands: `dev db start|stop|status|shell|reset|import`, `dev serve frontend|backend`, `dev artisan ...`, `dev down`. See `dev help`. The local DB listens on `127.0.0.1:3307` (override with `DEV_DB_PORT`); the `dev` script injects `DB_*`, `APP_DEBUG=true`, `TEST_LOCAL=true` via the process environment so each app's `.env` is left untouched. Ports: `DEV_FRONTEND_PORT`, `DEV_BACKEND_PORT`.