Move application migrations from framework to application directory
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
<?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 projects (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
site_id BIGINT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description LONGTEXT,
|
||||
client_id BIGINT NOT NULL,
|
||||
client_department_id BIGINT NULL,
|
||||
contact_id BIGINT NULL,
|
||||
status BIGINT NOT NULL DEFAULT 1,
|
||||
priority BIGINT NOT NULL DEFAULT 2,
|
||||
start_date DATE NULL,
|
||||
due_date DATE NULL,
|
||||
completed_date DATE NULL,
|
||||
budget DECIMAL(15, 2) NULL,
|
||||
notes LONGTEXT,
|
||||
created_by BIGINT NULL,
|
||||
owner_user_id BIGINT 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 NULL,
|
||||
|
||||
INDEX idx_site_id (site_id),
|
||||
INDEX idx_client_id (client_id),
|
||||
INDEX idx_client_department_id (client_department_id),
|
||||
INDEX idx_contact_id (contact_id),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_priority (priority),
|
||||
INDEX idx_created_by (created_by),
|
||||
INDEX idx_owner_user_id (owner_user_id),
|
||||
INDEX idx_created_at (created_at),
|
||||
INDEX idx_updated_at (updated_at),
|
||||
INDEX idx_name (name)
|
||||
) 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.
|
||||
*/
|
||||
};
|
||||
@@ -1,64 +0,0 @@
|
||||
<?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 tasks (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
site_id BIGINT NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description LONGTEXT,
|
||||
taskable_type VARCHAR(255) NOT NULL,
|
||||
taskable_id BIGINT NOT NULL,
|
||||
status BIGINT NOT NULL DEFAULT 1,
|
||||
priority BIGINT NOT NULL DEFAULT 2,
|
||||
due_date DATE NULL,
|
||||
completed_date DATE NULL,
|
||||
assigned_to_user_id BIGINT NULL,
|
||||
notes LONGTEXT,
|
||||
created_by BIGINT 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 NULL,
|
||||
|
||||
INDEX idx_site_id (site_id),
|
||||
INDEX idx_taskable (taskable_type, taskable_id),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_priority (priority),
|
||||
INDEX idx_assigned_to_user_id (assigned_to_user_id),
|
||||
INDEX idx_created_by (created_by),
|
||||
INDEX idx_created_at (created_at),
|
||||
INDEX idx_updated_at (updated_at),
|
||||
INDEX idx_title (title)
|
||||
) 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.
|
||||
*/
|
||||
};
|
||||
@@ -1,58 +0,0 @@
|
||||
<?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()
|
||||
{
|
||||
// Add new columns to existing clients table
|
||||
DB::statement("
|
||||
ALTER TABLE clients
|
||||
ADD COLUMN email VARCHAR(255) NULL AFTER website,
|
||||
ADD COLUMN fax VARCHAR(50) NULL AFTER phone,
|
||||
ADD COLUMN address_street VARCHAR(255) NULL COMMENT 'renamed from address',
|
||||
ADD COLUMN address_country VARCHAR(100) NULL DEFAULT 'USA',
|
||||
ADD COLUMN industry VARCHAR(100) NULL,
|
||||
ADD COLUMN company_size VARCHAR(20) NULL COMMENT '1-10, 11-50, 51-200, 201-500, 501-1000, 1000+',
|
||||
ADD COLUMN established_year BIGINT NULL,
|
||||
ADD COLUMN revenue_range VARCHAR(50) NULL,
|
||||
ADD COLUMN facebook_url VARCHAR(255) NULL,
|
||||
ADD COLUMN twitter_handle VARCHAR(100) NULL,
|
||||
ADD COLUMN linkedin_url VARCHAR(255) NULL,
|
||||
ADD COLUMN instagram_handle VARCHAR(100) NULL,
|
||||
ADD COLUMN tags JSON NULL,
|
||||
ADD COLUMN status VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, inactive, prospect, archived',
|
||||
ADD COLUMN preferred_contact_method VARCHAR(20) NULL DEFAULT 'email' COMMENT 'email, phone, text, any',
|
||||
ADD COLUMN newsletter_opt_in TINYINT(1) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN deleted_at TIMESTAMP NULL DEFAULT NULL,
|
||||
ADD INDEX idx_email (email),
|
||||
ADD INDEX idx_status (status),
|
||||
ADD INDEX idx_deleted_at (deleted_at)
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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 core_tables ADD COLUMN new_field VARCHAR(255)")
|
||||
* ❌ Schema::table() with Blueprint
|
||||
*
|
||||
* Migrations must be self-contained - no Model/Service references
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Note: clients table already has soft delete columns from previous migration
|
||||
|
||||
// Add soft delete columns to contacts table
|
||||
DB::statement("ALTER TABLE contacts ADD COLUMN deleted_at TIMESTAMP NULL DEFAULT NULL AFTER updated_by");
|
||||
DB::statement("ALTER TABLE contacts ADD COLUMN deleted_by BIGINT NULL DEFAULT NULL AFTER deleted_at");
|
||||
DB::statement("ALTER TABLE contacts ADD INDEX idx_deleted_at (deleted_at)");
|
||||
|
||||
// Add soft delete columns to projects table
|
||||
DB::statement("ALTER TABLE projects ADD COLUMN deleted_at TIMESTAMP NULL DEFAULT NULL AFTER updated_by");
|
||||
DB::statement("ALTER TABLE projects ADD COLUMN deleted_by BIGINT NULL DEFAULT NULL AFTER deleted_at");
|
||||
DB::statement("ALTER TABLE projects ADD INDEX idx_deleted_at (deleted_at)");
|
||||
|
||||
// Add soft delete columns to tasks table
|
||||
DB::statement("ALTER TABLE tasks ADD COLUMN deleted_at TIMESTAMP NULL DEFAULT NULL AFTER updated_by");
|
||||
DB::statement("ALTER TABLE tasks ADD COLUMN deleted_by BIGINT NULL DEFAULT NULL AFTER deleted_at");
|
||||
DB::statement("ALTER TABLE tasks ADD INDEX idx_deleted_at (deleted_at)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
};
|
||||
Reference in New Issue
Block a user