Fix bin/publish: copy docs.dist from project root

Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-21 02:08:33 +00:00
commit f6fac6c4bc
79758 changed files with 10547827 additions and 0 deletions

1
database/.gitignore vendored Executable file
View File

@@ -0,0 +1 @@
*.sqlite*

0
database/.vscode/.placeholder vendored Executable file
View File

View File

View File

@@ -0,0 +1,191 @@
{
"description": "This file tracks migrations created via php artisan make:migration",
"purpose": "Prevents manually created migrations from running to avoid timestamp conflicts",
"migrations": {
"2024_01_01_000000_create_sessions_table.php": {
"created_at": "pre-whitelist",
"created_by": "system",
"command": "existing migration"
},
"2025_08_13_155818_create_authorized_table.php": {
"created_at": "2025-08-13T15:58:21+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_authorized_table"
},
"2025_08_19_003042_test_raw_sql.php": {
"created_at": "2025-08-19T00:30:44+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_raw_sql"
},
"2025_09_03_054656_create_sites_table.php": {
"created_at": "2025-09-03T05:46:56+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_sites_table"
},
"2025_09_03_054826_create_users_table.php": {
"created_at": "2025-09-03T05:48:26+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_users_table"
},
"2025_09_03_054939_create_rsx_sessions_table.php": {
"created_at": "2025-09-03T05:49:39+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_rsx_sessions_table"
},
"2025_09_03_054950_create_site_users_table.php": {
"created_at": "2025-09-03T05:49:50+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_site_users_table"
},
"2025_09_03_054950_create_file_hashes_table.php": {
"created_at": "2025-09-03T05:49:50+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_file_hashes_table"
},
"2025_09_03_054950_create_files_table.php": {
"created_at": "2025-09-03T05:49:50+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_files_table"
},
"2025_09_03_054950_create_ip_addresses_table.php": {
"created_at": "2025-09-03T05:49:50+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_ip_addresses_table"
},
"2025_09_03_054951_create_user_verifications_table.php": {
"created_at": "2025-09-03T05:49:51+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_user_verifications_table"
},
"2025_09_03_054951_create_user_invites_table.php": {
"created_at": "2025-09-03T05:49:51+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_user_invites_table"
},
"2025_09_03_152057_create_admin_test_user.php": {
"created_at": "2025-09-03T15:20:57+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_admin_test_user"
},
"2025_09_03_164754_add_rsx_columns_to_sessions_table.php": {
"created_at": "2025-09-03T16:47:54+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_rsx_columns_to_sessions_table"
},
"2025_09_03_165609_create_flash_alerts_table.php": {
"created_at": "2025-09-03T16:56:09+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_flash_alerts_table"
},
"2025_09_09_102518_create_flash_alerts_table.php": {
"created_at": "2025-09-09T10:25:18+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_flash_alerts_table"
},
"2025_09_09_173210_update_flash_alerts_foreign_key_cascade.php": {
"created_at": "2025-09-09T17:32:10+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe update_flash_alerts_foreign_key_cascade"
},
"2025_09_09_202949_test_manifest_clear_on_migrate.php": {
"created_at": "2025-09-09T20:29:49+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_manifest_clear_on_migrate"
},
"2025_09_11_234657_test_unran_migration.php": {
"created_at": "2025-09-11T23:46:57+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_unran_migration"
},
"2025_09_11_234729_create_test_table_with_bad_session_id.php": {
"created_at": "2025-09-11T23:47:29+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_test_table_with_bad_session_id"
},
"2025_09_11_235349_fix_flash_alerts_session_id_schema.php": {
"created_at": "2025-09-11T23:53:49+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe fix_flash_alerts_session_id_schema"
},
"2025_09_12_185559_add_csrf_token_to_sessions_table.php": {
"created_at": "2025-09-12T18:55:59+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_csrf_token_to_sessions_table"
},
"2025_09_12_220225_add_composite_index_to_sessions_table.php": {
"created_at": "2025-09-12T22:02:25+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_composite_index_to_sessions_table"
},
"2025_09_16_074547_add_status_to_users_table.php": {
"created_at": "2025-09-16T07:45:47+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_status_to_users_table"
},
"2025_09_16_075234_rename_status_column_to_status_id.php": {
"created_at": "2025-09-16T07:52:34+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe rename_status_column_to_status_id"
},
"2025_09_16_075915_create_demo_products_table.php": {
"created_at": "2025-09-16T07:59:15+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_demo_products_table"
},
"2025_09_16_080116_fix_flash_alerts_foreign_key.php": {
"created_at": "2025-09-16T08:01:16+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe fix_flash_alerts_foreign_key"
},
"2025_09_30_023430_drop_and_recreate_session_table.php": {
"created_at": "2025-09-30T02:34:30+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe drop_and_recreate_session_table"
},
"2025_09_30_050004_add_last_login_to_users_table.php": {
"created_at": "2025-09-30T05:00:05+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_last_login_to_users_table"
},
"2025_10_13_012323_create_test_integers_table.php": {
"created_at": "2025-10-13T01:23:23+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_test_integers_table"
},
"2025_10_13_013341_create_test_types_table.php": {
"created_at": "2025-10-13T01:33:41+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_test_types_table"
},
"2025_10_13_013419_create_test_charset_table.php": {
"created_at": "2025-10-13T01:34:19+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe create_test_charset_table"
},
"2025_10_13_013631_test_forbidden_enum.php": {
"created_at": "2025-10-13T01:36:31+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_forbidden_enum"
},
"2025_10_13_013704_test_forbidden_set_year_time.php": {
"created_at": "2025-10-13T01:37:04+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_forbidden_set_year_time"
},
"2025_10_13_013949_test_edge_cases_comprehensive.php": {
"created_at": "2025-10-13T01:39:49+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_edge_cases_comprehensive"
},
"2025_10_13_020245_test_datetime_fk.php": {
"created_at": "2025-10-13T02:02:45+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe test_datetime_fk"
},
"2025_10_14_172351_add_experience_id_to_sessions.php": {
"created_at": "2025-10-14T17:23:51+00:00",
"created_by": "root",
"command": "php artisan make:migration:safe add_experience_id_to_sessions"
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE sessions (
id VARCHAR(255) NOT NULL PRIMARY KEY,
user_id BIGINT UNSIGNED NULL,
ip_address VARCHAR(45) NULL,
user_agent TEXT NULL,
payload LONGTEXT NOT NULL,
last_activity INT NOT NULL,
INDEX idx_user_id (user_id),
INDEX idx_last_activity (last_activity)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
};

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE sites (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(100) NOT NULL,
name VARCHAR(255) NOT NULL,
is_enabled TINYINT(1) NOT NULL DEFAULT 1,
deleted_at TIMESTAMP NULL DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_sites_slug (slug),
INDEX idx_sites_is_enabled (is_enabled),
INDEX idx_sites_deleted_at (deleted_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class () extends Migration {
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* Derpy derp herp..
*
* @return void
*/
public function up()
{
DB::statement('
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
is_activated TINYINT(1) NOT NULL DEFAULT 0,
is_verified TINYINT(1) NOT NULL DEFAULT 0,
remember_token VARCHAR(100) NULL DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_users_email (email),
INDEX idx_users_is_activated (is_activated),
INDEX idx_users_is_verified (is_verified)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
');
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE file_hashes (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
hash VARCHAR(128) NOT NULL,
mime_type VARCHAR(100) NULL DEFAULT NULL,
size BIGINT NOT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_file_hashes_hash (hash),
INDEX idx_file_hashes_mime_type (mime_type),
INDEX idx_file_hashes_size (size)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE files (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`key` VARCHAR(128) NOT NULL,
file_hash_id BIGINT NOT NULL,
file_name VARCHAR(255) NULL DEFAULT NULL,
file_extension VARCHAR(20) NULL DEFAULT NULL,
file_type_id BIGINT NULL DEFAULT NULL,
file_size BIGINT NOT NULL,
fileable_type VARCHAR(100) NULL DEFAULT NULL,
fileable_id BIGINT NULL DEFAULT NULL,
fileable_category VARCHAR(50) NULL DEFAULT NULL,
fileable_order BIGINT NULL DEFAULT NULL,
site_id BIGINT NOT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_files_key (`key`),
INDEX idx_files_file_hash_id (file_hash_id),
INDEX idx_files_site_id (site_id),
INDEX idx_files_fileable (fileable_type, fileable_id),
INDEX idx_files_file_type_id (file_type_id),
FOREIGN KEY (file_hash_id) REFERENCES file_hashes(id) ON DELETE RESTRICT,
FOREIGN KEY (site_id) REFERENCES sites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE ip_addresses (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
ip_address VARCHAR(45) NOT NULL,
city VARCHAR(100) NULL DEFAULT NULL,
state VARCHAR(100) NULL DEFAULT NULL,
country VARCHAR(100) NULL DEFAULT NULL,
lat FLOAT NULL DEFAULT NULL,
lng FLOAT NULL DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_ip_addresses_ip (ip_address),
INDEX idx_ip_addresses_country (country),
INDEX idx_ip_addresses_location (lat, lng)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE site_users (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT NOT NULL,
site_id BIGINT NOT NULL,
first_name VARCHAR(100) NULL DEFAULT NULL,
last_name VARCHAR(100) NULL DEFAULT NULL,
role_id BIGINT NULL DEFAULT NULL,
is_enabled TINYINT(1) NOT NULL DEFAULT 1,
deleted_at TIMESTAMP NULL DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_site_users_user_site (user_id, site_id),
INDEX idx_site_users_site_id (site_id),
INDEX idx_site_users_role_id (role_id),
INDEX idx_site_users_is_enabled (is_enabled),
INDEX idx_site_users_deleted_at (deleted_at),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (site_id) REFERENCES sites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE user_invites (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT NOT NULL,
site_id BIGINT NOT NULL,
invite_code VARCHAR(100) NOT NULL,
expires_at TIMESTAMP NOT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY uk_user_invites_code (invite_code),
INDEX idx_user_invites_user_id (user_id),
INDEX idx_user_invites_site_id (site_id),
INDEX idx_user_invites_expires_at (expires_at),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (site_id) REFERENCES sites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
CREATE TABLE user_verifications (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
verification_code VARCHAR(100) NOT NULL,
verification_type_id BIGINT NOT NULL,
verified_at TIMESTAMP NULL DEFAULT NULL,
expires_at TIMESTAMP NOT NULL,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
INDEX idx_user_verifications_email (email),
INDEX idx_user_verifications_code (verification_code),
INDEX idx_user_verifications_type (verification_type_id),
INDEX idx_user_verifications_expires_at (expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Create admin test user using environment variables or defaults
$email = env('RSPADE_DEFAULT_EMAIL', 'admin@test.com');
$password = env('RSPADE_DEFAULT_PASSWORD', 'admintest99');
$hashed_password = password_hash($password, PASSWORD_BCRYPT);
DB::statement("
INSERT INTO users (
email,
password,
is_activated,
is_verified,
created_at,
updated_at
) VALUES (
'" . $email . "',
'" . $hashed_password . "',
1,
1,
NOW(),
NOW()
)
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE sessions ADD COLUMN new_field VARCHAR(255)")
* Schema::table() with Blueprint
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("
ALTER TABLE sessions
ADD COLUMN session_id BIGINT NOT NULL AUTO_INCREMENT UNIQUE FIRST,
ADD COLUMN site_id BIGINT NULL AFTER user_id,
ADD KEY sessions_session_id_index (session_id),
ADD KEY sessions_site_id_index (site_id)
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Drop existing table if it exists
DB::statement("DROP TABLE IF EXISTS flash_alerts");
DB::statement("
CREATE TABLE flash_alerts (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
session_id VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
class_attribute VARCHAR(255) NOT NULL DEFAULT 'alert alert-danger alert-flash',
created_at TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3),
INDEX idx_session_id (session_id),
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Drop the existing foreign key constraint
DB::statement("ALTER TABLE flash_alerts DROP FOREIGN KEY flash_alerts_ibfk_1");
// Recreate the foreign key with ON DELETE CASCADE
DB::statement("
ALTER TABLE flash_alerts
ADD CONSTRAINT flash_alerts_ibfk_1
FOREIGN KEY (session_id)
REFERENCES sessions(id)
ON DELETE CASCADE
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE users ADD COLUMN age BIGINT")
* Schema::table() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Fix flash_alerts table to comply with schema standards:
// 1. Drop existing foreign key constraint
DB::statement("ALTER TABLE flash_alerts DROP FOREIGN KEY flash_alerts_ibfk_1");
// 2. Make session_id nullable
DB::statement("ALTER TABLE flash_alerts MODIFY session_id VARCHAR(255) NULL");
// 3. Add proper foreign key constraint with ON DELETE CASCADE
DB::statement("ALTER TABLE flash_alerts ADD CONSTRAINT flash_alerts_session_fk
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE sessions ADD COLUMN new_field VARCHAR(255)")
* Schema::table() with Blueprint
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
DB::statement("ALTER TABLE sessions ADD COLUMN csrf_token VARCHAR(255) NULL AFTER payload");
DB::statement("ALTER TABLE sessions ADD INDEX idx_csrf_token (csrf_token)");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE users ADD COLUMN new_field VARCHAR(255)")
* Schema::table() with Blueprint
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Add status column (1=active, 2=inactive, 3=suspended)
DB::statement("ALTER TABLE users ADD COLUMN status TINYINT NOT NULL DEFAULT 1 AFTER is_verified");
DB::statement("ALTER TABLE users ADD INDEX idx_status (status)");
// Add user_role_id column (1=read_only, 2=standard, 3=admin, 4=billing_admin, 5=root_admin)
DB::statement("ALTER TABLE users ADD COLUMN user_role_id TINYINT NOT NULL DEFAULT 2 AFTER status");
DB::statement("ALTER TABLE users ADD INDEX idx_user_role_id (user_role_id)");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE status_id ADD COLUMN new_field VARCHAR(255)")
* Schema::table() with Blueprint
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Rename status column to status_id to match enum naming convention
DB::statement("ALTER TABLE users CHANGE COLUMN status status_id TINYINT NOT NULL DEFAULT 1");
// Recreate the index with the new column name
DB::statement("ALTER TABLE users DROP INDEX idx_status");
DB::statement("ALTER TABLE users ADD INDEX idx_status_id (status_id)");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement() with raw SQL
* Schema::create() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Create demo_products table for Ajax ORM demonstration
DB::statement("
CREATE TABLE demo_products (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL,
status_id TINYINT NOT NULL DEFAULT 1,
category_id TINYINT NOT NULL DEFAULT 1,
created_at TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3),
updated_at TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
INDEX idx_status_id (status_id),
INDEX idx_category_id (category_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
// Insert demo data
DB::statement("
INSERT INTO demo_products (name, description, price, status_id, category_id) VALUES
('Wireless Mouse', 'Ergonomic wireless mouse with 2.4GHz connectivity', 29.99, 1, 1),
('Vintage T-Shirt', 'Classic cotton t-shirt with retro design', 19.99, 1, 2),
('JavaScript: The Good Parts', 'Essential guide to JavaScript programming', 39.99, 2, 3),
('Premium Coffee Beans', 'Single-origin Arabica beans from Colombia', 24.99, 1, 4),
('Gaming Laptop', 'High-performance laptop with RTX graphics', 1299.99, 3, 1)
");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE users ADD COLUMN age BIGINT")
* Schema::table() with Blueprint
*
* REQUIRED: ALL tables MUST have: id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
* No exceptions - every table needs this exact ID column (SIGNED for easier migrations)
*
* Integer types: Use BIGINT for all integers, TINYINT(1) for booleans only
* Never use unsigned - all integers should be signed
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Fix flash_alerts foreign key to include ON DELETE CASCADE
DB::statement("ALTER TABLE flash_alerts DROP FOREIGN KEY flash_alerts_session_fk");
DB::statement("ALTER TABLE flash_alerts ADD CONSTRAINT flash_alerts_session_fk FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

View File

@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Drop foreign key constraint from flash_alerts table first
DB::statement('ALTER TABLE flash_alerts DROP FOREIGN KEY flash_alerts_session_fk');
// Delete all flash_alerts records since session IDs will be incompatible
DB::statement('DELETE FROM flash_alerts');
// Convert flash_alerts.session_id from varchar to bigint
DB::statement('ALTER TABLE flash_alerts MODIFY session_id BIGINT NULL');
// Drop existing sessions table
DB::statement('DROP TABLE IF EXISTS sessions');
// Create new session table based on RS3 specification with security enhancements
DB::statement("
CREATE TABLE sessions (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
active TINYINT(1) NOT NULL DEFAULT 1,
site_id BIGINT NULL DEFAULT 0,
user_id BIGINT NULL,
session_token VARCHAR(64) NOT NULL,
csrf_token VARCHAR(64) NULL,
ip_address VARCHAR(45) NOT NULL,
user_agent VARCHAR(255) NULL,
last_active DATETIME NOT NULL,
version INT NOT NULL DEFAULT 1,
created_at TIMESTAMP NULL DEFAULT NULL,
updated_at TIMESTAMP NULL DEFAULT NULL,
UNIQUE KEY sessions_session_token_unique (session_token),
INDEX sessions_active_index (active),
INDEX sessions_user_id_index (user_id),
INDEX sessions_last_active_index (last_active),
INDEX sessions_active_last_active_index (active, last_active),
INDEX sessions_user_id_active_index (user_id, active)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
// Re-add foreign key constraint from flash_alerts table
DB::statement('ALTER TABLE flash_alerts ADD CONSTRAINT flash_alerts_session_fk FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE');
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Add last_login column to users table
DB::statement("ALTER TABLE users ADD COLUMN last_login TIMESTAMP NULL DEFAULT NULL");
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Use raw MySQL queries for clarity and auditability
* DB::statement("ALTER TABLE sessions ADD COLUMN new_field VARCHAR(255)")
* Schema::table() with Blueprint
*
* Migrations must be self-contained - no Model/Service references
*
* @return void
*/
public function up()
{
// Add experience_id column to sessions table
// Experience ID represents the authentication realm (default=0, staff=1, customer=2, etc.)
// Allows users to be logged into multiple experiences simultaneously
DB::statement("ALTER TABLE sessions ADD COLUMN experience_id INT DEFAULT 0 NOT NULL");
// Add index for experience_id lookups
DB::statement("ALTER TABLE sessions ADD INDEX idx_experience_id (experience_id)");
// Add composite index for common query pattern (token + experience lookup)
DB::statement("ALTER TABLE sessions ADD INDEX idx_token_experience (session_token, experience_id)");
}
/**
* down() method is prohibited in RSpade framework
* Migrations should only move forward, never backward
* You may remove this comment as soon as you see it and understand.
*/
};

65
database/migrations/CLAUDE.md Executable file
View File

@@ -0,0 +1,65 @@
# Migrations Directory
This CLAUDE.md file contains a brief synopsis of the purpose of this directory, then a list of files in this directory with the file sizes of each file, and a short description and relevant key points of information for every file which is important in this directory. Unimportant files like images or temporary data directories are not listed in this file. When visiting this directory, the AI agent is instructed to do an ls on the directory to get the directory contents and file sizes - and if the file size diverges from the size in CLAUDE.md, that means the file has changed, and the description in CLAUDE.md is not up to date. This doesn't trigger this to be regenerated immediately, but let's say we wanted to know about a specific file by viewing CLAUDE.md and we discovered it was out of date, we would need to reread and update the documentation for that file in the CLAUDE.md at that time before we considered any details about it. CLAUDE.md might also contain other bits of information that is critical to know if you are looking at notes in the directory where the CLAUDE.md file lives.
## Directory Purpose
The Migrations directory contains database migration files that define the database schema and its evolution over time. Laravel migrations provide a version control system for the database, allowing developers to modify the database schema in a structured and organized way. This directory includes migrations for all aspects of the application, from user authentication to content management and multi-tenant functionality.
## Directory Organization
This directory contains approximately 60 migration files in the root directory and additional migrations in two subdirectories:
1. **multi_tenant/** - Contains 10 migrations specific to multi-tenant functionality
2. **rspade/** - Contains 10 migrations for the RSpade application component
Due to the large number of migration files, this document provides a categorical overview rather than listing each file individually.
## Migration Categories
| Category | Date Range | Description |
|----------|------------|-------------|
| **Authentication/User System** | 2014-2019 | Laravel's default auth tables including users, password resets, failed jobs, and personal access tokens. Forms the foundation of the authentication system. |
| **Core DMR System** | 2025-05-10 | Initial system functionality including bridges, operators, talkgroups, and bridge links. These form the core domain objects of the application. |
| **Content Management** | 2025-05-10/11 | Text blocks, static blocks, and blog posts that provide content management capabilities throughout the application. |
| **Communication Features** | 2025-05-11 | Messages and notifications system for user-to-user communication and system notifications. |
| **Knowledge Base** | 2025-05-11 | Knowledge base articles and related functionality for information sharing. |
| **To-do System** | 2025-05-15 | Todo lists, todo items, and sharing functionality in the RSpade subdirectory. |
| **Multi-tenant Architecture** | 2025-05-15/16 | Sites, organizations, invitations, and user associations in the multi_tenant subdirectory. |
| **File Management** | 2024-05-15 | File uploads and management system for handling various file types. |
## Implementation Patterns
1. **SQL Implementation Approaches**:
- Earlier migrations use raw SQL with `DB::unprepared()`
- Later migrations use Laravel's Schema Builder for better readability and maintainability
2. **Common Features**:
- Soft deletes (`deleted_at` columns) for all major entities
- Tracking columns (created_at, updated_at) for audit purposes
- Extensive use of indexes for performance optimization
- Foreign key constraints for data integrity
- Timestamp-based naming convention (YYYY_MM_DD_HHMMSS_action_table.php)
3. **Migration Flow**:
- Forward-only migrations (down methods often minimal)
- Progressive schema evolution with additive changes
- Fix migrations to address issues in previous migrations
## Notable Migration Files
While there are too many files to list individually, some key migrations include:
1. `2014_10_12_000000_create_users_table.php` - Initial users table
2. `2025_05_10_045605_create_bridges_table.php` - Core bridge functionality
3. `2025_05_11_081546_create_knowledge_base_articles_table.php` - Knowledge base system
4. `2025_05_15_000011_create_sites_table.php` - Multi-tenant site functionality
5. `2025_05_15_000001_create_todo_lists_table.php` - Todo list functionality
## Working with Migrations
1. To run migrations: `php artisan migrate`
2. To create a new migration: `php artisan make:migration name_of_migration`
3. To roll back the last batch: `php artisan migrate:rollback`
When modifying the database schema, always create a new migration rather than modifying existing ones to maintain data integrity in production environments.

View File

0
database/seeders/.placeholder Executable file
View File