Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
64
app/RSpade/tests/_lib/db_reset.sh
Executable file
64
app/RSpade/tests/_lib/db_reset.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RSpade Test Database Reset Script
|
||||
#
|
||||
# Drops and recreates rspade_test database, then either:
|
||||
# 1. Restores from snapshot (fast) + runs any new migrations
|
||||
# 2. Runs all migrations from scratch (slow, if no snapshot exists)
|
||||
#
|
||||
# MUST be called from within test mode (after test_mode_enter)
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SNAPSHOT_FILE="$SCRIPT_DIR/test_db_snapshot.sql"
|
||||
|
||||
# SAFETY CHECK: Ensure we're in test mode
|
||||
if ! grep -q "^DB_DATABASE=rspade_test" /var/www/html/.env; then
|
||||
echo "FATAL ERROR: db_reset.sh must be called from within test mode!" >&2
|
||||
echo "" >&2
|
||||
echo "Current database: $(grep "^DB_DATABASE=" /var/www/html/.env | cut -d= -f2)" >&2
|
||||
echo "" >&2
|
||||
echo "This is a safety check to prevent accidentally resetting the production database." >&2
|
||||
echo "" >&2
|
||||
echo "Correct usage:" >&2
|
||||
echo " source /system/app/RSpade/tests/_lib/test_env.sh" >&2
|
||||
echo " test_mode_enter" >&2
|
||||
echo " _lib/db_reset.sh" >&2
|
||||
echo " # ... run tests ..." >&2
|
||||
echo " test_mode_exit" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "^RSX_ADDITIONAL_CONFIG=.*rsx_test_config.php" /var/www/html/.env; then
|
||||
echo "FATAL ERROR: Test config not loaded!" >&2
|
||||
echo "" >&2
|
||||
echo "RSX_ADDITIONAL_CONFIG must point to rsx_test_config.php when running tests." >&2
|
||||
echo "This should be set automatically by test_mode_enter." >&2
|
||||
echo "" >&2
|
||||
echo "Current RSX_ADDITIONAL_CONFIG: $(grep "^RSX_ADDITIONAL_CONFIG=" /var/www/html/.env || echo 'NOT SET')" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[DB RESET] Dropping rspade_test database..." >&2
|
||||
mysql -h127.0.0.1 -urspade -prspadepass -e "DROP DATABASE IF EXISTS rspade_test" 2>/dev/null
|
||||
|
||||
echo "[DB RESET] Creating rspade_test database..." >&2
|
||||
mysql -h127.0.0.1 -urspade -prspadepass -e "CREATE DATABASE rspade_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" 2>/dev/null
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
if [ -f "$SNAPSHOT_FILE" ]; then
|
||||
# Fast path: Restore from snapshot
|
||||
echo "[DB RESET] Restoring from snapshot..." >&2
|
||||
mysql -h127.0.0.1 -urspade -prspadepass rspade_test < "$SNAPSHOT_FILE" 2>/dev/null
|
||||
|
||||
# Run any new migrations that were added after snapshot
|
||||
echo "[DB RESET] Running new migrations..." >&2
|
||||
php artisan migrate --production 2>&1 | grep -v "Nothing to migrate" >&2
|
||||
else
|
||||
# Slow path: Run all migrations from scratch
|
||||
echo "[DB RESET] No snapshot found, running all migrations..." >&2
|
||||
echo "[DB RESET] (Create snapshot with: _lib/db_snapshot_create.sh)" >&2
|
||||
php artisan migrate --production 2>&1 | grep -v "Nothing to migrate" >&2
|
||||
fi
|
||||
|
||||
echo "[DB RESET] Database reset complete" >&2
|
||||
103
app/RSpade/tests/_lib/db_snapshot_create.sh
Executable file
103
app/RSpade/tests/_lib/db_snapshot_create.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RSpade Test Database Snapshot Creator
|
||||
#
|
||||
# Creates a pristine snapshot of the test database after running all migrations.
|
||||
# This snapshot can be used to speed up test database resets.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SNAPSHOT_FILE="$SCRIPT_DIR/test_db_snapshot.sql"
|
||||
FULL_OUTPUT=false
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--full-output)
|
||||
FULL_OUTPUT=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "[SNAPSHOT] Creating pristine test database snapshot..." >&2
|
||||
|
||||
# Source test environment helpers
|
||||
source "$SCRIPT_DIR/test_env.sh"
|
||||
|
||||
# Ensure test mode exits on script exit (success or failure)
|
||||
trap test_trap_exit EXIT
|
||||
|
||||
# Reset database and run ALL migrations from scratch
|
||||
echo "[SNAPSHOT] Resetting test database..." >&2
|
||||
|
||||
if [ "$FULL_OUTPUT" = true ]; then
|
||||
# Show full migration output
|
||||
"$SCRIPT_DIR/db_reset.sh"
|
||||
else
|
||||
# Suppress output, capture errors
|
||||
TEMP_OUTPUT="/tmp/snapshot_output_$$"
|
||||
if ! "$SCRIPT_DIR/db_reset.sh" > "$TEMP_OUTPUT" 2>&1; then
|
||||
echo "" >&2
|
||||
echo "[ERROR] Database provisioning failed" >&2
|
||||
echo "[ERROR] Run with --full-output to see details:" >&2
|
||||
echo "[ERROR] $0 --full-output" >&2
|
||||
echo "" >&2
|
||||
cat "$TEMP_OUTPUT" >&2
|
||||
rm -f "$TEMP_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$TEMP_OUTPUT"
|
||||
fi
|
||||
|
||||
# Enter test mode to verify database is accessible
|
||||
test_mode_enter > /dev/null 2>&1
|
||||
|
||||
# Verify migrations ran
|
||||
migration_count=$(test_db_query "SELECT COUNT(*) FROM migrations")
|
||||
if [ -z "$migration_count" ] || [ "$migration_count" -eq 0 ]; then
|
||||
echo "[ERROR] No migrations found in database" >&2
|
||||
echo "[ERROR] Run with --full-output to see details:" >&2
|
||||
echo "[ERROR] $0 --full-output" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[SNAPSHOT] Found $migration_count migrations" >&2
|
||||
|
||||
# Exit test mode before dump
|
||||
test_mode_exit > /dev/null 2>&1
|
||||
|
||||
# Create snapshot
|
||||
echo "[SNAPSHOT] Creating snapshot file..." >&2
|
||||
|
||||
# Backup current .env
|
||||
SNAPSHOT_ENV_BACKUP="/tmp/rspade_snapshot_backup_$$"
|
||||
cp /var/www/html/.env "$SNAPSHOT_ENV_BACKUP"
|
||||
|
||||
# Switch to test database for dump
|
||||
sed -i 's/^DB_DATABASE=.*$/DB_DATABASE=rspade_test/' /var/www/html/.env
|
||||
php artisan config:clear > /dev/null 2>&1
|
||||
|
||||
# Create dump
|
||||
if ! mysqldump -h127.0.0.1 -urspade -prspadepass rspade_test \
|
||||
--no-tablespaces \
|
||||
--single-transaction \
|
||||
--quick \
|
||||
--lock-tables=false \
|
||||
> "$SNAPSHOT_FILE" 2>/dev/null; then
|
||||
echo "[ERROR] Failed to create database dump" >&2
|
||||
mv "$SNAPSHOT_ENV_BACKUP" /var/www/html/.env
|
||||
php artisan config:clear > /dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Restore original .env
|
||||
mv "$SNAPSHOT_ENV_BACKUP" /var/www/html/.env
|
||||
php artisan config:clear > /dev/null 2>&1
|
||||
|
||||
# Get snapshot size
|
||||
snapshot_size=$(du -h "$SNAPSHOT_FILE" | cut -f1)
|
||||
|
||||
echo "[SNAPSHOT] Snapshot created successfully ($snapshot_size)" >&2
|
||||
echo "[SNAPSHOT] Tests will now use this snapshot for faster database resets" >&2
|
||||
18
app/RSpade/tests/_lib/rsx_test_config.php
Executable file
18
app/RSpade/tests/_lib/rsx_test_config.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* RSpade Test Configuration
|
||||
*
|
||||
* Additional configuration loaded when RSX_ADDITIONAL_CONFIG env variable is set.
|
||||
* Used by test runner to include tests directory in manifest scanning.
|
||||
*
|
||||
* Loaded by: test_mode_enter.sh
|
||||
* Cleared by: test_mode_exit.sh
|
||||
*/
|
||||
|
||||
return [
|
||||
'manifest' => [
|
||||
'scan_directories' => [
|
||||
'app/RSpade/tests', // Include framework tests directory in manifest
|
||||
],
|
||||
],
|
||||
];
|
||||
928
app/RSpade/tests/_lib/test_db_snapshot.sql
Executable file
928
app/RSpade/tests/_lib/test_db_snapshot.sql
Executable file
@@ -0,0 +1,928 @@
|
||||
-- MySQL dump 10.13 Distrib 8.0.43, for Linux (x86_64)
|
||||
--
|
||||
-- Host: 127.0.0.1 Database: rspade_test
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 8.0.43-0ubuntu0.22.04.2
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8mb4 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `client_departments`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `client_departments`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `client_departments` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`site_id` bigint NOT NULL,
|
||||
`client_id` bigint NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_site_id` (`site_id`),
|
||||
KEY `idx_client_id` (`client_id`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
CONSTRAINT `fk_client_departments_client` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `client_departments`
|
||||
--
|
||||
|
||||
LOCK TABLES `client_departments` WRITE;
|
||||
/*!40000 ALTER TABLE `client_departments` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `client_departments` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `clients`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `clients`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `clients` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`site_id` bigint NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`address` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`zip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`fax` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone_secondary` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`website` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`billing_contact_id` bigint DEFAULT NULL,
|
||||
`priority` bigint NOT NULL DEFAULT '2',
|
||||
`notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`owner_user_id` bigint DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`address_street` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'renamed from address',
|
||||
`address_country` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'USA',
|
||||
`industry` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`company_size` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '1-10, 11-50, 51-200, 201-500, 501-1000, 1000+',
|
||||
`established_year` bigint DEFAULT NULL,
|
||||
`revenue_range` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`facebook_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`twitter_handle` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`linkedin_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`instagram_handle` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`tags` json DEFAULT NULL,
|
||||
`status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT 'active, inactive, prospect, archived',
|
||||
`preferred_contact_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'email' COMMENT 'email, phone, LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, any',
|
||||
`newsletter_opt_in` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_site_id` (`site_id`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_created_by_user_id` (`created_by`),
|
||||
KEY `idx_owner_user_id` (`owner_user_id`),
|
||||
KEY `idx_billing_contact_id` (`billing_contact_id`),
|
||||
KEY `idx_priority` (`priority`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_email` (`email`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_deleted_at` (`deleted_at`),
|
||||
CONSTRAINT `fk_clients_billing_contact` FOREIGN KEY (`billing_contact_id`) REFERENCES `contacts` (`id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `clients`
|
||||
--
|
||||
|
||||
LOCK TABLES `clients` WRITE;
|
||||
/*!40000 ALTER TABLE `clients` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `clients` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `contacts`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `contacts`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `contacts` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`site_id` bigint NOT NULL,
|
||||
`client_id` bigint NOT NULL,
|
||||
`first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`client_department_id` bigint DEFAULT NULL,
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`email_secondary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone_work` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone_cell` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone_other` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`address` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`zip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`reports_to_contact_id` bigint DEFAULT NULL,
|
||||
`is_active` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`priority` bigint NOT NULL DEFAULT '2',
|
||||
`notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`owner_user_id` bigint DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_site_id` (`site_id`),
|
||||
KEY `idx_client_id` (`client_id`),
|
||||
KEY `idx_first_name` (`first_name`),
|
||||
KEY `idx_last_name` (`last_name`),
|
||||
KEY `idx_email` (`email`),
|
||||
KEY `idx_client_department_id` (`client_department_id`),
|
||||
KEY `idx_reports_to_contact_id` (`reports_to_contact_id`),
|
||||
KEY `idx_is_active` (`is_active`),
|
||||
KEY `idx_priority` (`priority`),
|
||||
KEY `idx_created_by_user_id` (`created_by`),
|
||||
KEY `idx_owner_user_id` (`owner_user_id`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_deleted_at` (`deleted_at`),
|
||||
CONSTRAINT `fk_contacts_client` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_contacts_department` FOREIGN KEY (`client_department_id`) REFERENCES `client_departments` (`id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_contacts_reports_to` FOREIGN KEY (`reports_to_contact_id`) REFERENCES `contacts` (`id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `contacts`
|
||||
--
|
||||
|
||||
LOCK TABLES `contacts` WRITE;
|
||||
/*!40000 ALTER TABLE `contacts` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `contacts` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `countries`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `countries`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `countries` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`alpha2` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'ISO 3166-1 alpha-2 code (US, CA, GB)',
|
||||
`alpha3` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'ISO 3166-1 alpha-3 code (USA, CAN, GBR)',
|
||||
`numeric` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'ISO 3166-1 numeric code (840, 124, 826)',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Official country name',
|
||||
`common_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Common name if different from official',
|
||||
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Active status - disable instead of delete to preserve FKs',
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `alpha2` (`alpha2`),
|
||||
KEY `idx_alpha2` (`alpha2`),
|
||||
KEY `idx_alpha3` (`alpha3`),
|
||||
KEY `idx_enabled` (`enabled`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `countries`
|
||||
--
|
||||
|
||||
LOCK TABLES `countries` WRITE;
|
||||
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `demo_products`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `demo_products`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `demo_products` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`price` decimal(10,2) NOT NULL,
|
||||
`status_id` bigint NOT NULL DEFAULT '1',
|
||||
`category_id` bigint NOT NULL DEFAULT '1',
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_status_id` (`status_id`),
|
||||
KEY `idx_category_id` (`category_id`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `demo_products`
|
||||
--
|
||||
|
||||
LOCK TABLES `demo_products` WRITE;
|
||||
/*!40000 ALTER TABLE `demo_products` DISABLE KEYS */;
|
||||
INSERT INTO `demo_products` VALUES (1,'Wireless Mouse','Ergonomic wireless mouse with 2.4GHz connectivity',29.99,1,1,'2025-11-16 19:37:32.241','2025-11-16 19:37:32.241',NULL,NULL),(2,'Vintage T-Shirt','Classic cotton t-shirt with retro design',19.99,1,2,'2025-11-16 19:37:32.241','2025-11-16 19:37:32.241',NULL,NULL),(3,'JavaScript: The Good Parts','Essential guide to JavaScript programming',39.99,2,3,'2025-11-16 19:37:32.241','2025-11-16 19:37:32.241',NULL,NULL),(4,'Premium Coffee Beans','Single-origin Arabica beans from Colombia',24.99,1,4,'2025-11-16 19:37:32.241','2025-11-16 19:37:32.241',NULL,NULL),(5,'Gaming Laptop','High-performance laptop with RTX graphics',1299.99,3,1,'2025-11-16 19:37:32.241','2025-11-16 19:37:32.241',NULL,NULL);
|
||||
/*!40000 ALTER TABLE `demo_products` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `file_attachments`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `file_attachments`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `file_attachments` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`key` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`file_storage_id` bigint NOT NULL,
|
||||
`file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`file_extension` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`file_type_id` bigint DEFAULT NULL,
|
||||
`width` bigint DEFAULT NULL COMMENT 'Width in pixels for images/videos',
|
||||
`height` bigint DEFAULT NULL COMMENT 'Height in pixels for images/videos',
|
||||
`duration` bigint DEFAULT NULL COMMENT 'Duration in seconds for videos/animated images',
|
||||
`is_animated` tinyint(1) DEFAULT '0' COMMENT 'Whether this is an animated image (GIF, WebP, APNG)',
|
||||
`frame_count` bigint DEFAULT NULL COMMENT 'Number of frames in animated images',
|
||||
`fileable_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`fileable_id` bigint DEFAULT NULL,
|
||||
`fileable_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`fileable_type_meta` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`fileable_order` bigint DEFAULT NULL,
|
||||
`fileable_meta` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`site_id` bigint NOT NULL,
|
||||
`session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_files_key` (`key`),
|
||||
KEY `idx_files_file_hash_id` (`file_storage_id`),
|
||||
KEY `idx_files_site_id` (`site_id`),
|
||||
KEY `idx_files_fileable` (`fileable_type`,`fileable_id`),
|
||||
KEY `idx_files_file_type_id` (`file_type_id`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_file_attachments_type_meta` (`fileable_type_meta`),
|
||||
KEY `idx_session_id` (`session_id`),
|
||||
CONSTRAINT `file_attachments_ibfk_1` FOREIGN KEY (`file_storage_id`) REFERENCES `file_storage` (`id`) ON DELETE RESTRICT,
|
||||
CONSTRAINT `file_attachments_ibfk_2` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `file_attachments`
|
||||
--
|
||||
|
||||
LOCK TABLES `file_attachments` WRITE;
|
||||
/*!40000 ALTER TABLE `file_attachments` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `file_attachments` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `file_storage`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `file_storage`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `file_storage` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`hash` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`size` bigint NOT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_file_hashes_hash` (`hash`),
|
||||
KEY `idx_file_hashes_size` (`size`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `file_storage`
|
||||
--
|
||||
|
||||
LOCK TABLES `file_storage` WRITE;
|
||||
/*!40000 ALTER TABLE `file_storage` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `file_storage` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `flash_alerts`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `flash_alerts`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `flash_alerts` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`session_id` bigint DEFAULT NULL,
|
||||
`type_id` bigint NOT NULL,
|
||||
`message` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_session_id` (`session_id`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
CONSTRAINT `flash_alerts_session_fk` FOREIGN KEY (`session_id`) REFERENCES `sessions` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `flash_alerts`
|
||||
--
|
||||
|
||||
LOCK TABLES `flash_alerts` WRITE;
|
||||
/*!40000 ALTER TABLE `flash_alerts` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `flash_alerts` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `ip_addresses`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `ip_addresses`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `ip_addresses` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`state` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`country` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`lat` double DEFAULT NULL,
|
||||
`lng` double DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_ip_addresses_ip` (`ip_address`),
|
||||
KEY `idx_ip_addresses_country` (`country`),
|
||||
KEY `idx_ip_addresses_location` (`lat`,`lng`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `ip_addresses`
|
||||
--
|
||||
|
||||
LOCK TABLES `ip_addresses` WRITE;
|
||||
/*!40000 ALTER TABLE `ip_addresses` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `ip_addresses` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `login_users`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `login_users`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `login_users` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`is_activated` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_verified` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`status_id` bigint NOT NULL DEFAULT '1',
|
||||
`remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`last_login` timestamp(3) NULL DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_login_users_email` (`email`),
|
||||
KEY `idx_login_users_is_activated` (`is_activated`),
|
||||
KEY `idx_login_users_is_verified` (`is_verified`),
|
||||
KEY `idx_login_users_status_id` (`status_id`),
|
||||
KEY `idx_login_users_created_at` (`created_at`),
|
||||
KEY `idx_login_users_updated_at` (`updated_at`),
|
||||
KEY `idx_login_users_last_login` (`last_login`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `login_users`
|
||||
--
|
||||
|
||||
LOCK TABLES `login_users` WRITE;
|
||||
/*!40000 ALTER TABLE `login_users` DISABLE KEYS */;
|
||||
INSERT INTO `login_users` VALUES (1,'admin@test.com','$2y$10$jROh4YFvV3tNRCPLrNgmC.aIJfP.yLkUZCY39fNuKcWJ16h9xlhe.',1,1,1,NULL,NULL,'2025-11-16 19:37:30.000','2025-11-16 19:37:30.000',NULL,NULL);
|
||||
/*!40000 ALTER TABLE `login_users` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `migrations`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `migrations`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `migrations` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`batch` bigint NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `migrations`
|
||||
--
|
||||
|
||||
LOCK TABLES `migrations` WRITE;
|
||||
/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
|
||||
INSERT INTO `migrations` VALUES (1,'2024_01_01_000000_create_sessions_table',1),(2,'2025_09_03_054656_create_sites_table',2),(3,'2025_09_03_054826_create_users_table',3),(4,'2025_09_03_054950_create_file_hashes_table',4),(5,'2025_09_03_054950_create_files_table',5),(6,'2025_09_03_054950_create_ip_addresses_table',6),(7,'2025_09_03_054950_create_site_users_table',7),(8,'2025_09_03_054951_create_user_invites_table',8),(9,'2025_09_03_054951_create_user_verifications_table',9),(10,'2025_09_03_152057_create_admin_test_user',10),(11,'2025_09_03_164754_add_rsx_columns_to_sessions_table',11),(12,'2025_09_09_102518_create_flash_alerts_table',12),(13,'2025_09_09_173210_update_flash_alerts_foreign_key_cascade',13),(14,'2025_09_11_235349_fix_flash_alerts_session_id_schema',14),(15,'2025_09_12_185559_add_csrf_token_to_sessions_table',15),(16,'2025_09_16_074547_add_status_to_users_table',16),(17,'2025_09_16_075234_rename_status_column_to_status_id',17),(18,'2025_09_16_075915_create_demo_products_table',18),(19,'2025_09_16_080116_fix_flash_alerts_foreign_key',19),(20,'2025_09_30_023430_drop_and_recreate_session_table',20),(21,'2025_09_30_050004_add_last_login_to_users_table',21),(22,'2025_10_14_172351_add_experience_id_to_sessions',22),(23,'2025_10_28_223500_create_geographic_data_tables',23),(24,'2025_11_02_063218_rename_file_tables_for_storage_attachment_refactor',24),(25,'2025_11_02_065329_add_metadata_fields_to_file_attachments',25),(26,'2025_11_02_065347_create_file_thumbnails_table',26),(27,'2025_11_02_070055_create_search_indexes_table',27),(28,'2025_11_02_162826_add_dimensions_to_file_attachments',28),(29,'2025_11_04_011033_add_name_and_phone_columns_to_users_table',29),(30,'2025_11_04_011050_create_user_profiles_table',30),(31,'2025_11_04_014825_add_session_id_to_file_attachments_table',31),(32,'2025_11_04_051746_create_login_users_table',32),(33,'2025_11_04_051828_refactor_site_users_to_users_table',33),(34,'2025_11_04_051907_update_sessions_table_for_login_user_id',34),(35,'2025_11_04_051935_update_user_profiles_foreign_key',35),(36,'2025_11_04_181832_add_invite_columns_to_users_table',36),(37,'2025_11_05_012345_make_login_user_id_nullable_in_users_table',37),(38,'2025_11_13_193740_modify_flash_alerts_table_for_type_based_system',38),(39,'2025_11_16_093331_drop_file_thumbnails_table',39),(40,'2025_10_10_021141_create_companies_table',40),(41,'2025_10_10_021204_create_company_departments_table',41),(42,'2025_10_10_021223_create_contacts_table',42),(43,'2025_10_10_021244_add_billing_contact_foreign_key_to_companies',43),(44,'2025_10_28_025035_create_projects_table',44),(45,'2025_10_28_025113_create_tasks_table',45),(46,'2025_10_28_043559_create_clients_table',46),(47,'2025_10_29_034934_add_soft_deletes_to_core_tables',47);
|
||||
/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `projects`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `projects`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `projects` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`site_id` bigint NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`client_id` bigint NOT NULL,
|
||||
`client_department_id` bigint DEFAULT NULL,
|
||||
`contact_id` bigint DEFAULT NULL,
|
||||
`status` bigint NOT NULL DEFAULT '1',
|
||||
`priority` bigint NOT NULL DEFAULT '2',
|
||||
`start_date` date DEFAULT NULL,
|
||||
`due_date` date DEFAULT NULL,
|
||||
`completed_date` date DEFAULT NULL,
|
||||
`budget` decimal(15,2) DEFAULT NULL,
|
||||
`notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`owner_user_id` bigint DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_site_id` (`site_id`),
|
||||
KEY `idx_client_id` (`client_id`),
|
||||
KEY `idx_client_department_id` (`client_department_id`),
|
||||
KEY `idx_contact_id` (`contact_id`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_priority` (`priority`),
|
||||
KEY `idx_created_by` (`created_by`),
|
||||
KEY `idx_owner_user_id` (`owner_user_id`),
|
||||
KEY `idx_created_at` (`created_at`),
|
||||
KEY `idx_updated_at` (`updated_at`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_deleted_at` (`deleted_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `projects`
|
||||
--
|
||||
|
||||
LOCK TABLES `projects` WRITE;
|
||||
/*!40000 ALTER TABLE `projects` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `projects` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `regions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `regions`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `regions` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'ISO 3166-2 code (US-CA, CA-ON, GB-ENG)',
|
||||
`country_alpha2` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Foreign key to countries.alpha2',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Subdivision name (California, Ontario, England)',
|
||||
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Type: state, province, territory, country, etc.',
|
||||
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Active status - disable instead of delete',
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_country_code` (`country_alpha2`,`code`),
|
||||
KEY `idx_country` (`country_alpha2`),
|
||||
KEY `idx_code` (`code`),
|
||||
KEY `idx_enabled` (`enabled`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
CONSTRAINT `fk_regions_country` FOREIGN KEY (`country_alpha2`) REFERENCES `countries` (`alpha2`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `regions`
|
||||
--
|
||||
|
||||
LOCK TABLES `regions` WRITE;
|
||||
/*!40000 ALTER TABLE `regions` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `regions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `search_indexes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `search_indexes`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `search_indexes` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`indexable_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`indexable_id` bigint NOT NULL,
|
||||
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`metadata` json DEFAULT NULL,
|
||||
`indexed_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`extraction_method` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`language` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`site_id` bigint NOT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_indexable` (`indexable_type`,`indexable_id`),
|
||||
KEY `idx_indexable` (`indexable_type`,`indexable_id`),
|
||||
KEY `idx_site` (`site_id`),
|
||||
KEY `idx_language` (`language`),
|
||||
KEY `idx_indexed_at` (`indexed_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
FULLTEXT KEY `ft_content` (`content`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `search_indexes`
|
||||
--
|
||||
|
||||
LOCK TABLES `search_indexes` WRITE;
|
||||
/*!40000 ALTER TABLE `search_indexes` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `search_indexes` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `sessions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `sessions`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `sessions` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`active` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`site_id` bigint DEFAULT '0',
|
||||
`login_user_id` bigint DEFAULT NULL,
|
||||
`session_token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`csrf_token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`last_active` datetime(3) NOT NULL,
|
||||
`version` bigint NOT NULL DEFAULT '1',
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`experience_id` bigint NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `sessions_session_token_unique` (`session_token`),
|
||||
KEY `sessions_active_index` (`active`),
|
||||
KEY `sessions_last_active_index` (`last_active`),
|
||||
KEY `sessions_active_last_active_index` (`active`,`last_active`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_experience_id` (`experience_id`),
|
||||
KEY `idx_token_experience` (`session_token`,`experience_id`),
|
||||
KEY `idx_sessions_login_user_id` (`login_user_id`),
|
||||
KEY `idx_sessions_login_user_id_active` (`login_user_id`,`active`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `sessions`
|
||||
--
|
||||
|
||||
LOCK TABLES `sessions` WRITE;
|
||||
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `sites`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `sites`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `sites` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`slug` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`is_enabled` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_sites_slug` (`slug`),
|
||||
KEY `idx_sites_is_enabled` (`is_enabled`),
|
||||
KEY `idx_sites_deleted_at` (`deleted_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `sites`
|
||||
--
|
||||
|
||||
LOCK TABLES `sites` WRITE;
|
||||
/*!40000 ALTER TABLE `sites` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `sites` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `tasks`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `tasks`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `tasks` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`site_id` bigint NOT NULL,
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`taskable_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`taskable_id` bigint NOT NULL,
|
||||
`status` bigint NOT NULL DEFAULT '1',
|
||||
`priority` bigint NOT NULL DEFAULT '2',
|
||||
`due_date` date DEFAULT NULL,
|
||||
`completed_date` date DEFAULT NULL,
|
||||
`assigned_to_user_id` bigint DEFAULT NULL,
|
||||
`notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_site_id` (`site_id`),
|
||||
KEY `idx_taskable` (`taskable_type`,`taskable_id`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_priority` (`priority`),
|
||||
KEY `idx_assigned_to_user_id` (`assigned_to_user_id`),
|
||||
KEY `idx_created_by` (`created_by`),
|
||||
KEY `idx_created_at` (`created_at`),
|
||||
KEY `idx_updated_at` (`updated_at`),
|
||||
KEY `idx_title` (`title`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_deleted_at` (`deleted_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `tasks`
|
||||
--
|
||||
|
||||
LOCK TABLES `tasks` WRITE;
|
||||
/*!40000 ALTER TABLE `tasks` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `tasks` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `user_invites`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user_invites`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_invites` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint NOT NULL,
|
||||
`site_id` bigint NOT NULL,
|
||||
`invite_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`expires_at` timestamp(3) NOT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_user_invites_code` (`invite_code`),
|
||||
KEY `idx_user_invites_user_id` (`user_id`),
|
||||
KEY `idx_user_invites_site_id` (`site_id`),
|
||||
KEY `idx_user_invites_expires_at` (`expires_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
CONSTRAINT `fk_user_invites_user_id` FOREIGN KEY (`user_id`) REFERENCES `login_users` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `user_invites_ibfk_2` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user_invites`
|
||||
--
|
||||
|
||||
LOCK TABLES `user_invites` WRITE;
|
||||
/*!40000 ALTER TABLE `user_invites` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `user_invites` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `user_profiles`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user_profiles`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_profiles` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint NOT NULL,
|
||||
`title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`department` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`bio` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
CONSTRAINT `fk_user_profiles_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user_profiles`
|
||||
--
|
||||
|
||||
LOCK TABLES `user_profiles` WRITE;
|
||||
/*!40000 ALTER TABLE `user_profiles` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `user_profiles` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `user_verifications`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `user_verifications`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `user_verifications` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`verification_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`verification_type_id` bigint NOT NULL,
|
||||
`verified_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`expires_at` timestamp(3) NOT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_user_verifications_email` (`email`),
|
||||
KEY `idx_user_verifications_code` (`verification_code`),
|
||||
KEY `idx_user_verifications_type` (`verification_type_id`),
|
||||
KEY `idx_user_verifications_expires_at` (`expires_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `user_verifications`
|
||||
--
|
||||
|
||||
LOCK TABLES `user_verifications` WRITE;
|
||||
/*!40000 ALTER TABLE `user_verifications` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `user_verifications` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `users`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `users`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `users` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`login_user_id` bigint DEFAULT NULL,
|
||||
`site_id` bigint NOT NULL,
|
||||
`first_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`last_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`role_id` bigint DEFAULT NULL,
|
||||
`is_enabled` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`user_role_id` bigint NOT NULL DEFAULT '2',
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`deleted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`created_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` timestamp(3) NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
`created_by` bigint DEFAULT NULL,
|
||||
`updated_by` bigint DEFAULT NULL,
|
||||
`deleted_by` bigint DEFAULT NULL,
|
||||
`invite_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`invite_accepted_at` timestamp(3) NULL DEFAULT NULL,
|
||||
`invite_expires_at` timestamp(3) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_users_login_user_site` (`login_user_id`,`site_id`),
|
||||
UNIQUE KEY `uk_users_invite_code` (`invite_code`),
|
||||
KEY `idx_site_users_site_id` (`site_id`),
|
||||
KEY `idx_site_users_role_id` (`role_id`),
|
||||
KEY `idx_site_users_is_enabled` (`is_enabled`),
|
||||
KEY `idx_site_users_deleted_at` (`deleted_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`),
|
||||
KEY `idx_users_phone` (`phone`),
|
||||
KEY `idx_users_user_role_id` (`user_role_id`),
|
||||
KEY `idx_users_email` (`email`),
|
||||
KEY `idx_users_invite_accepted_at` (`invite_accepted_at`),
|
||||
KEY `idx_users_invite_expires_at` (`invite_expires_at`),
|
||||
CONSTRAINT `fk_users_login_user_id` FOREIGN KEY (`login_user_id`) REFERENCES `login_users` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_users_site_id` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `users`
|
||||
--
|
||||
|
||||
LOCK TABLES `users` WRITE;
|
||||
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-11-16 19:45:00
|
||||
90
app/RSpade/tests/_lib/test_env.sh
Executable file
90
app/RSpade/tests/_lib/test_env.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
# RSpade Test Environment Helpers
|
||||
#
|
||||
# Manages test database environment and provides utilities for test setup/teardown
|
||||
|
||||
TEST_ENV_BACKUP="/var/www/html/system/.env.testbackup"
|
||||
TEST_MODE_ACTIVE=false
|
||||
|
||||
# Enter test mode - switch to test database
|
||||
function test_mode_enter() {
|
||||
if [ "$TEST_MODE_ACTIVE" = true ]; then
|
||||
echo "[ERROR] Test mode already active" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "[TEST ENV] Entering test mode..." >&2
|
||||
|
||||
# Only backup .env if we're NOT already in test mode
|
||||
# (Don't want to backup test config and mistake it for production)
|
||||
if grep -q "^DB_DATABASE=rspade_test" /var/www/html/.env; then
|
||||
echo "[TEST ENV] WARNING: Already using test database - NOT creating backup" >&2
|
||||
echo "[TEST ENV] This indicates .env was not properly restored from a previous test run" >&2
|
||||
echo "[TEST ENV] Manually restore /var/www/html/.env to production credentials before running tests" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Backup current .env (production credentials)
|
||||
cp /var/www/html/.env "$TEST_ENV_BACKUP"
|
||||
|
||||
# Switch to test database
|
||||
sed -i 's/^DB_DATABASE=.*$/DB_DATABASE=rspade_test/' /var/www/html/.env
|
||||
|
||||
# Add test config to include tests directory in manifest
|
||||
if ! grep -q "^RSX_ADDITIONAL_CONFIG=" /var/www/html/.env; then
|
||||
echo "RSX_ADDITIONAL_CONFIG=/var/www/html/system/app/RSpade/tests/_lib/rsx_test_config.php" >> /var/www/html/.env
|
||||
else
|
||||
sed -i 's|^RSX_ADDITIONAL_CONFIG=.*$|RSX_ADDITIONAL_CONFIG=/var/www/html/system/app/RSpade/tests/_lib/rsx_test_config.php|' /var/www/html/.env
|
||||
fi
|
||||
|
||||
# Clear Laravel config cache and rebuild manifest
|
||||
cd /var/www/html
|
||||
php artisan config:clear > /dev/null 2>&1
|
||||
php artisan rsx:clean > /dev/null 2>&1
|
||||
|
||||
TEST_MODE_ACTIVE=true
|
||||
echo "[TEST ENV] Test mode active (using rspade_test database)" >&2
|
||||
}
|
||||
|
||||
# Exit test mode - restore original database
|
||||
function test_mode_exit() {
|
||||
if [ "$TEST_MODE_ACTIVE" = false ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "[TEST ENV] Exiting test mode..." >&2
|
||||
|
||||
# Restore original .env
|
||||
if [ -f "$TEST_ENV_BACKUP" ]; then
|
||||
mv "$TEST_ENV_BACKUP" /var/www/html/.env
|
||||
fi
|
||||
|
||||
# Clear Laravel config cache and rebuild manifest
|
||||
cd /var/www/html
|
||||
php artisan config:clear > /dev/null 2>&1
|
||||
php artisan rsx:clean > /dev/null 2>&1
|
||||
|
||||
TEST_MODE_ACTIVE=false
|
||||
echo "[TEST ENV] Test mode exited (restored original database)" >&2
|
||||
}
|
||||
|
||||
# Trap to ensure test mode always exits
|
||||
function test_trap_exit() {
|
||||
test_mode_exit
|
||||
|
||||
# NEVER remove backup files - they contain production credentials
|
||||
# Backup files are process-specific (/tmp/rspade_test_env_backup_$$)
|
||||
# and will be cleaned up by system /tmp cleanup
|
||||
}
|
||||
|
||||
# Query helper for test database
|
||||
function test_db_query() {
|
||||
mysql -h127.0.0.1 -urspade -prspadepass rspade_test -N -e "$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Count helper for test database
|
||||
function test_db_count() {
|
||||
local table=$1
|
||||
test_db_query "SELECT COUNT(*) FROM $table"
|
||||
}
|
||||
Reference in New Issue
Block a user