# Walink / WaLinks Database Migration & Installation Guide

This package contains complete database schemas and all live link data, destination agents, click logs, and workspaces exported from Supabase PostgreSQL.

---

## 📁 Included Files
1. `walinks-supabase-migration.sql`: Executable PostgreSQL DDL schema & data migration with `INSERT ... ON CONFLICT DO NOTHING`.
2. `walinks-database-export.json`: Full structured JSON dump of all schemas, table row counts, and data.
3. `installer.php`: Self-contained web installer for Apache / Nginx / XAMPP / cPanel `htdocs`.
4. `migrate.js`: Automated Node.js migration installer.

---

## 🚀 Option A: Upload to `htdocs` (Apache / XAMPP / cPanel / Shared Hosting)
1. Copy `installer.php` and `walinks-database-export.json` (or `walinks-supabase-migration.sql`) into your web server's `htdocs` or `public_html` directory.
2. Open your browser and navigate to:
   ```
   http://your-server-ip-or-domain/installer.php
   ```
3. Enter your database connection details (PostgreSQL or MySQL).
4. Click **"Execute Migration & Install Data"**.
5. All links, destination agents, and click telemetry will be installed automatically!

---

## 🚀 Option B: Restore to Any PostgreSQL or Supabase Instance
Using `psql`:
```bash
psql -h your-new-db-host -U postgres -d postgres -f walinks-supabase-migration.sql
```

---

## 🚀 Option C: Automated Node.js Migration
```bash
DATABASE_URL=postgresql://user:password@host:5432/dbname node migrate.js
```

---

## 🚀 Option D: In-App UI Restore
1. Open the Walink dashboard at `/app/settings`.
2. Navigate to **"Server Migration & Backup"**.
3. Upload `walinks-database-export.json` or `walinks-supabase-migration.sql`.
4. Click **"Restore & Sync to Database"**.
