Files
MoneyFlix/crm/Core/Database/Migrations/CreateDashboardWidgetsSystem.php
T
1sonhador 9d43854277 feat: Initial MoneyFlix project setup
- Created separate MoneyFlix project directory
- Copied Node.js redirector from production server
- Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views)
- Created comprehensive documentation (README_MONEYFLIX.md)
- Added sync script to keep CRM code updated (sync-from-crm.sh)
- Configured .gitignore for Node.js and PHP
- Set up proper project structure for multi-client isolation

This separates MoneyFlix from the main CRM to avoid confusion
between different client systems and provides a dedicated
environment for MoneyFlix-specific development and maintenance.
2025-10-03 12:09:41 +01:00

81 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
use App\Core\Database\Migration;
/**
* Create dashboard widgets system
*
* Migration to create tables for modular dashboard widgets system
* allowing users to customize their dashboard with module-specific widgets.
*/
class CreateDashboardWidgetsSystem extends Migration
{
/**
* Run the migration
*/
public function up(): void
{
// Create dashboard_widgets table - Available widgets from modules
$this->createTable('dashboard_widgets', function($table) {
$table->bigInteger('id')->autoIncrement()->notNull()
->string('widget_id', 100)->notNull()->comment('Unique widget identifier')
->string('module_name', 100)->notNull()->comment('Module that provides this widget')
->string('widget_name', 255)->notNull()->comment('Display name of widget')
->text('widget_description')->nullable()->comment('Widget description')
->string('widget_class', 255)->notNull()->comment('PHP class that renders the widget')
->string('widget_method', 100)->default('render')->comment('Method to call for rendering')
->json('default_config')->nullable()->comment('Default widget configuration')
->string('widget_size', 20)->default('medium')->comment('small, medium, large, full')
->string('widget_category', 100)->default('general')->comment('Widget category for organization')
->tinyInteger('is_active')->default(1)->notNull()->comment('1=active, 0=inactive')
->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull()
->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull()
->primaryKey('id')
->unique('widget_id')
->index('module_name')
->index('widget_category')
->index('is_active');
});
// Create user_dashboard_widgets table - User's personalized dashboard
$this->createTable('user_dashboard_widgets', function($table) {
$table->bigInteger('id')->autoIncrement()->notNull()
->bigInteger('user_id')->notNull()->comment('User who owns this dashboard configuration')
->string('widget_id', 100)->notNull()->comment('Reference to dashboard_widgets.widget_id')
->integer('position_order')->default(0)->comment('Display order on dashboard')
->string('widget_size', 20)->nullable()->comment('User override for widget size')
->json('widget_config')->nullable()->comment('User-specific widget configuration')
->tinyInteger('is_visible')->default(1)->notNull()->comment('1=visible, 0=hidden')
->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull()
->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull()
->primaryKey('id')
->uniqueComposite('uk_user_widget', ['user_id', 'widget_id'])
->index('user_id')
->index('position_order')
->index('is_visible');
});
echo "Created dashboard widgets system tables\n";
}
/**
* Reverse the migration
*/
public function down(): void
{
$this->dropTable('user_dashboard_widgets');
$this->dropTable('dashboard_widgets');
echo "Removed dashboard widgets system tables\n";
}
/**
* Get migration description
*/
public function getDescription(): string
{
return 'Create dashboard widgets system for modular customizable dashboard';
}
}