feat: implement barangay system phases 2-14
Some checks failed
tests / PHP 8.2 (swoole-5.1.6) (push) Has been cancelled
tests / PHP 8.3 (swoole-5.1.6) (push) Has been cancelled
tests / PHP 8.4 (swoole-6.0) (push) Has been cancelled

Complete adaptation from BukidBountyApp to Philippine barangay governance:

- Barangay models: Resident, Household, HouseholdMember, Blotter, BlotterHearing,
  DocumentRequest, RequestPayment, RequestType, BarangayProject, BarangayBudget
- Controllers: ResidentController, HouseholdController, BlotterController,
  BlotterHearingController, DocumentRequestController, RequestTypeController,
  ProjectController, BudgetController, QRPHController, AdminConsoleController,
  UserController, FileController, ChapterController, LoginController
- Vue pages: Home, ManageResidents, ResidentProfile, ManageHouseholds, ManageBlotters,
  BlotterDetail, RequestDocument, ManageDocumentRequests, DocumentRequestDetail,
  ManageRequestTypes, ManageProjects, BudgetLedger, AdminConsole
- Barangay roles: PunongBarangay, Kagawad, Secretary, Treasurer, SK, Tanod, BHW, Staff, Resident
- UserPermissions matrix rewritten with barangay-specific permission mappings
- VueRouteMap replaced with barangay SPA routes
- UserActions enum references corrected across all controllers
- Removed all market/cooperative/POS/subscription code and models
This commit is contained in:
Jonathan Sykes
2026-06-07 03:09:09 +08:00
parent 19fec0933b
commit fbb7e3ff37
234 changed files with 5582 additions and 39457 deletions

View File

@@ -1,240 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('str', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('storecode', 50)->default('');
$table->string('name', 150)->nullable();
$table->text('description')->nullable();
$table->timestamps();
$table->json('store_type')->nullable();
$table->string('status', 50)->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('updated_by')->references('id')->on('users');
$table->unsignedBigInteger('created_for')->nullable();
$table->foreign('created_for')->references('id')->on('users');
// $table->foreignId('created_by')->constrained('users')->nullable();
// $table->foreignId('updated_by')->constrained('users')->nullable();
// $table->foreignId('created_for')->constrained('users')->nullable();
$table->string('remarks', 50)->nullable();
$table->longText('logs')->nullable();
$table->json('specs')->nullable();
$table->longText('additionaldata')->nullable();
// $table->foreignId('owner_id')->constrained('users')->nullable();
// $table->foreignId('manager_id')->constrained('users')->nullable();
$table->unsignedBigInteger('owner_id')->nullable();
$table->foreign('owner_id')->references('id')->on('users');
$table->unsignedBigInteger('manager_id')->nullable();
$table->foreign('manager_id')->references('id')->on('users');
$table->string('category', 50)->nullable();
$table->string('subcategory', 50)->nullable();
$table->json('photourl')->nullable();
$table->text('address')->nullable();
$table->boolean('is_active')->default(true);
// Indexes
$table->index('storecode');
$table->index('name');
$table->index('status');
$table->index('created_by');
$table->index('created_for');
$table->index('owner_id');
$table->index('manager_id');
});
Schema::create('prd_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->timestamps();
// $table->foreignId('created_by')->constrained('users')->nullable();
// $table->foreignId('updated_by')->constrained('users')->nullable();
// $table->foreignId('created_for')->constrained('users')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('updated_by')->references('id')->on('users');
$table->unsignedBigInteger('created_for')->nullable();
$table->foreign('created_for')->references('id')->on('users');
$table->string('category', 50)->nullable();
$table->string('subcategory', 50)->nullable();
$table->longText('logs')->nullable();
$table->json('specs')->nullable();
$table->string('product_type')->nullable();
$table->json('photourl')->nullable();
$table->integer('available')->nullable();
$table->integer('sold')->nullable();
$table->bigInteger('price')->nullable();
// $table->foreignId('store_id')->constrained('stores')->nullable();
// $table->foreignId('owner_id')->constrained('users')->nullable();
$table->unsignedBigInteger('owner_id')->nullable();
$table->foreign('owner_id')->references('id')->on('users');
$table->boolean('is_active')->default(true);
$table->bigInteger('views')->nullable();
$table->string('name', 300)->nullable();
$table->longText('description')->nullable();
$table->json('reviews')->nullable();
$table->string('barcode', 50)->nullable();
$table->string('status', 50)->nullable();
$table->string('remarks', 150)->nullable();
$table->string('unitname', 300)->nullable();
$table->integer('rating')->nullable();
$table->string('sku', 50)->nullable();
$table->string('qrcode', 300)->nullable();
$table->string('shortcode', 50)->nullable();
$table->string('shortname', 50)->nullable();
$table->index('created_by');
$table->index('updated_by');
$table->index('created_for');
// $table->index('store_id');
$table->index('owner_id');
$table->index('category');
$table->index('subcategory');
});
// Products Transactions table
Schema::create('prd_trx', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->timestamps();
$table->text('description')->nullable();
$table->text('notes')->nullable();
$table->tinyInteger('transaction_type')->default(0);
$table->unsignedBigInteger('created_by')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('updated_by')->references('id')->on('users');
$table->unsignedBigInteger('created_for')->nullable();
$table->foreign('created_for')->references('id')->on('users');
$table->bigInteger('store_id')->nullable();
$table->string('transactiontype', 50)->nullable();
$table->bigInteger('product_id')->nullable();
$table->longText('transactiondata')->nullable();
$table->string('subtype', 50)->nullable();
$table->string('name', 300)->nullable();
// $table->bigInteger('owner_id')->nullable();
$table->unsignedBigInteger('owner_id')->nullable();
$table->foreign('owner_id')->references('id')->on('users');
$table->string('transactionsessionhash', 300)->unique()->nullable();
$table->bigInteger('quantity')->nullable();
$table->longText('logs')->nullable();
$table->string('remarks', 50)->nullable();
$table->integer('price')->nullable();
$table->boolean('is_void')->default(false);
$table->bigInteger('last_total_price')->nullable();
$table->bigInteger('last_total_discount')->nullable();
$table->index('created_by');
$table->index('updated_by');
$table->index('created_for');
$table->index('name');
$table->index('transactionsessionhash');
});
// Products Transactions Sessions table
Schema::create('prd_trx_ses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->timestamps();
$table->string('name', 300)->nullable();
$table->text('description')->nullable();
$table->longText('logs')->nullable();
$table->string('remarks', 300)->nullable();
$table->text('notes')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('updated_by')->references('id')->on('users');
$table->unsignedBigInteger('created_for')->nullable();
$table->foreign('created_for')->references('id')->on('users');
$table->string('subtype', 50)->nullable();
$table->longText('additionaldata')->nullable();
$table->string('category', 50)->nullable();
$table->bigInteger('store_id')->nullable();
$table->string('status', 50)->nullable();
$table->boolean('is_void')->default(false);
$table->bigInteger('last_total_price')->nullable();
$table->bigInteger('last_total_discount')->nullable();
$table->index('hashkey');
$table->index('created_by');
$table->index('updated_by');
$table->index('created_for');
});
Schema::create('prd_trx_ses_arc', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('name')->nullable();
$table->text('description')->nullable();
$table->json('details')->nullable();
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('transactions_sessions_id')->nullable();
$table->foreign('transactions_sessions_id')->references('id')->on('prd_trx_ses');
$table->text('notes')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('updated_by')->references('id')->on('users');
$table->unsignedBigInteger('created_for')->nullable();
$table->foreign('created_for')->references('id')->on('users');
$table->json('transactions_snapshot')->nullable();
$table->index('created_by');
$table->index('updated_by');
$table->index('created_for');
$table->index('hashkey');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('prd_trx_ses_arc');
Schema::dropIfExists('prd_trx_ses');
Schema::dropIfExists('prd_trx');
Schema::dropIfExists('prd_items_arc');
Schema::dropIfExists('prd_items');
Schema::dropIfExists('str');
}
};

View File

@@ -1,44 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('prd_str', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained('prd_items')->onDelete('cascade');
$table->foreignId('store_id')->constrained('str')->onDelete('cascade');
// Optional extra data per store-product relation
$table->integer('available')->nullable();
$table->bigInteger('price')->nullable();
$table->bigInteger('sold')->nullable();
$table->longText('logs')->nullable();
$table->json('reviews')->nullable();
$table->string('status', 50)->nullable();
$table->string('remarks', 150)->nullable();
$table->longText('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->unique(['product_id', 'store_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('prd_str');
}
};

View File

@@ -1,72 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
/**
* CHART OF ACCOUNTS (Self-Referencing)
*/
Schema::create('accounts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
// Self-referencing foreign key for nested accounts
$table->unsignedBigInteger('parent_id')->nullable();
$table->foreign('parent_id')->references('id')->on('accounts')->cascadeOnDelete();
$table->string('name')->index();
$table->string('type')->index(); // e.g., 'REVENUE', 'EXPENSE'
$table->string('description')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
/**
* ACCOUNT TRANSACTIONS
*/
Schema::create('account_transactions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
// Link to the lowest-level account
$table->unsignedBigInteger('account_id');
$table->foreign('account_id')->references('id')->on('accounts')->cascadeOnDelete();
$table->string('item')->index()->nullable();
$table->unsignedBigInteger('target_id')->nullable()->index(); // optional target (user, vendor)
$table->decimal('amount', 15, 2)->default(0);
$table->dateTime('transaction_date')->index();
$table->string('reference')->nullable()->index(); // external reference / invoice no.
$table->json('additional_details')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('account_transactions');
Schema::dropIfExists('accounts');
}
};

View File

@@ -1,46 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('global_transactions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('user_id')->index();
$table->decimal('amount', 15, 2)->default(0);
$table->integer('type')->default(0); // ProductTransactionType::UNKNOWN
$table->string('status', 50)->default('completed');
$table->text('description')->nullable();
$table->unsignedBigInteger('product_id')->nullable()->index();
$table->unsignedBigInteger('store_id')->nullable()->index();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('product_id')->references('id')->on('prd_items')->onDelete('set null');
$table->foreign('store_id')->references('id')->on('str')->onDelete('set null');
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('global_transactions');
}
};

View File

@@ -1,76 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pos_sessions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('access_key', 300)->unique(); // Guest access key
$table->unsignedBigInteger('store_id')->index();
$table->unsignedBigInteger('created_by')->nullable()->index();
$table->unsignedBigInteger('updated_by')->nullable()->index();
$table->string('customer_name', 300)->nullable();
$table->bigInteger('total_amount')->default(0);
$table->bigInteger('received_amount')->default(0);
$table->bigInteger('change_amount')->default(0);
$table->string('payment_method', 50)->nullable();
$table->json('payment_details')->nullable();
$table->string('status', 50)->default('active'); // active, completed, voided, pending
$table->boolean('is_void')->default(false);
$table->text('notes')->nullable();
$table->longText('additionaldata')->nullable();
$table->timestamps();
$table->foreign('created_by')->references('id')->on('users');
// Assuming a stores table exists, but following legacy pattern where it's bigint
});
Schema::create('pos_transactions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('pos_session_id')->index();
$table->unsignedBigInteger('product_id')->index();
$table->integer('quantity')->default(1);
$table->bigInteger('price_at_sale')->default(0);
$table->bigInteger('discount')->default(0);
$table->bigInteger('total_price')->default(0);
$table->boolean('is_void')->default(false);
$table->string('remarks', 300)->nullable();
$table->timestamps();
$table->foreign('pos_session_id')->references('id')->on('pos_sessions')->onDelete('cascade');
// product_id references prd_items.id
});
Schema::create('pos_sessions_archive', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('pos_session_id')->index();
$table->string('hashkey', 300)->index();
$table->json('session_snapshot')->nullable();
$table->json('transactions_snapshot')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->string('remarks', 300)->nullable();
$table->timestamps();
$table->foreign('pos_session_id')->references('id')->on('pos_sessions')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pos_sessions_archive');
Schema::dropIfExists('pos_transactions');
Schema::dropIfExists('pos_sessions');
}
};

View File

@@ -1,36 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pos_access_keys', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('access_key', 300)->unique();
$table->unsignedBigInteger('store_id')->index();
$table->string('name', 255)->nullable();
$table->string('status', 50)->default('active');
$table->timestamp('last_used_at')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
$table->foreign('store_id')->references('id')->on('str')->onDelete('cascade');
$table->foreign('created_by')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pos_access_keys');
}
};

View File

@@ -1,21 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::table('pos_access_keys', function (Blueprint $table) {
$table->timestamp('expires_at')->nullable()->after('status');
});
}
public function down(): void
{
Schema::table('pos_access_keys', function (Blueprint $table) {
$table->dropColumn('expires_at');
});
}
};

View File

@@ -1,39 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pos_sessions', function (Blueprint $table) {
if (!Schema::hasColumn('pos_sessions', 'updated_by')) {
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by')->index();
}
});
Schema::table('pos_sessions_archive', function (Blueprint $table) {
if (!Schema::hasColumn('pos_sessions_archive', 'updated_by')) {
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pos_sessions', function (Blueprint $table) {
$table->dropColumn('updated_by');
});
Schema::table('pos_sessions_archive', function (Blueprint $table) {
$table->dropColumn('updated_by');
});
}
};

View File

@@ -1,29 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pos_transactions', function (Blueprint $table) {
$table->string('hashkey', 300)->nullable()->unique()->after('id');
$table->unsignedBigInteger('created_by')->nullable()->after('remarks')->index();
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pos_transactions', function (Blueprint $table) {
$table->dropColumn(['hashkey', 'created_by', 'updated_by']);
});
}
};

View File

@@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pos_access_keys', function (Blueprint $table) {
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by');
$table->boolean('is_active')->default(true)->after('status');
$table->foreign('updated_by')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pos_access_keys', function (Blueprint $table) {
$table->dropForeign(['updated_by']);
$table->dropColumn(['updated_by', 'is_active']);
});
}
};

View File

@@ -1,27 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('global_transactions', function (Blueprint $table) {
$table->integer('flow')->default(0)->after('type'); // App\Enums\Market\TransactionFlow::NEUTRAL
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('global_transactions', function (Blueprint $table) {
$table->dropColumn('flow');
});
}
};

View File

@@ -1,29 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::create('cst', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('name', 255);
$table->string('phone', 50)->nullable();
$table->string('email', 255)->nullable();
$table->unsignedBigInteger('store_id')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('cst');
}
};

View File

@@ -1,30 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pos_sessions', function (Blueprint $table) {
$table->dropUnique('pos_sessions_access_key_unique');
$table->index('access_key');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pos_sessions', function (Blueprint $table) {
$table->dropIndex(['access_key']);
$table->unique('access_key');
});
}
};

View File

@@ -1,89 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
if (!Schema::hasTable('properties')) {
Schema::create('properties', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('name')->index();
$table->string('location')->nullable();
$table->decimal('price', 15, 2)->default(0);
$table->string('status')->default('available')->index();
$table->json('details')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
}
if (!Schema::hasTable('referral_keys')) {
Schema::create('referral_keys', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('user_id')->index();
$table->string('key')->unique()->index();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
}
if (!Schema::hasTable('referrals')) {
Schema::create('referrals', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('property_id')->index();
$table->unsignedBigInteger('referrer_id')->index();
$table->unsignedBigInteger('referred_id')->nullable()->index(); // Can be null if it's just a lead
$table->string('referred_name')->nullable();
$table->string('referred_contact')->nullable();
$table->string('status')->default('pending')->index();
$table->json('details')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('property_id')->references('id')->on('properties')->cascadeOnDelete();
$table->foreign('referrer_id')->references('id')->on('users')->cascadeOnDelete();
$table->foreign('referred_id')->references('id')->on('users')->nullOnDelete();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
}
}
public function down(): void
{
Schema::dropIfExists('referrals');
Schema::dropIfExists('referral_keys');
Schema::dropIfExists('properties');
}
};

View File

@@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('couriers', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->string('name');
$table->string('contact_number')->nullable();
$table->string('type', 50)->default('INTERNAL'); // INTERNAL, EXTERNAL
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('couriers');
}
};

View File

@@ -1,51 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('shipments', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('transaction_id')->index();
$table->unsignedBigInteger('store_id')->nullable()->index();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->unsignedBigInteger('courier_id')->nullable()->index();
$table->string('tracking_number')->unique()->nullable();
$table->string('status', 50)->default('PENDING'); // PENDING, PICKED_UP, IN_TRANSIT, DELIVERED, FAILED, RETURNED
$table->text('origin_address')->nullable();
$table->text('destination_address')->nullable();
$table->timestamp('estimated_delivery_date')->nullable();
$table->timestamp('actual_delivery_date')->nullable();
$table->decimal('shipping_fee', 15, 2)->default(0);
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('transaction_id')->references('id')->on('global_transactions')->onDelete('cascade');
$table->foreign('store_id')->references('id')->on('str')->onDelete('set null');
$table->foreign('customer_id')->references('id')->on('cst')->onDelete('set null');
$table->foreign('courier_id')->references('id')->on('couriers')->onDelete('set null');
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('shipments');
}
};

View File

@@ -1,60 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('organizations', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->string('name');
$table->string('type', 50)->default('COOPERATIVE'); // COOPERATIVE, ASSOCIATION, COMPANY
$table->text('address')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
Schema::create('farmer_profiles', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('organization_id')->nullable()->index();
$table->string('farm_name')->nullable();
$table->text('farm_location')->nullable();
$table->json('main_crops')->nullable();
$table->string('verification_status', 50)->default('UNVERIFIED'); // UNVERIFIED, PENDING, VERIFIED, REJECTED
$table->json('certification_details')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('organization_id')->references('id')->on('organizations')->onDelete('set null');
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('farmer_profiles');
Schema::dropIfExists('organizations');
}
};

View File

@@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cooperative_members', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('organization_id');
$table->unsignedBigInteger('user_id');
$table->string('role', 50)->default('MEMBER'); // MEMBER, OFFICER, ADMIN
$table->timestamp('joined_at')->nullable();
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cooperative_members');
}
};

View File

@@ -1,47 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('carts', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->boolean('is_active')->default(true);
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->timestamps();
});
Schema::create('cart_items', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->foreignId('cart_id')->constrained('carts')->onDelete('cascade');
$table->foreignId('product_id')->constrained('prd_items')->onDelete('cascade');
$table->integer('quantity')->default(1);
$table->decimal('price', 15, 2);
$table->boolean('is_active')->default(true);
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cart_items');
Schema::dropIfExists('carts');
}
};

View File

@@ -1,49 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->string('registration_number')->nullable()->after('address');
$table->string('cin')->nullable()->after('registration_number');
$table->string('tin')->nullable()->after('cin');
$table->string('cooperative_type')->nullable()->after('tin'); // e.g., Multi-purpose, Credit
$table->string('cooperative_category')->nullable()->after('cooperative_type'); // Micro, Small, Medium, Large
$table->date('registration_date')->nullable()->after('cooperative_category');
$table->string('contact_person')->nullable()->after('registration_date');
$table->string('contact_number')->nullable()->after('contact_person');
$table->string('contact_email')->nullable()->after('contact_number');
$table->string('compliance_status')->default('UNKNOWN')->after('contact_email');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->dropColumn([
'registration_number',
'cin',
'tin',
'cooperative_type',
'cooperative_category',
'registration_date',
'contact_person',
'contact_number',
'contact_email',
'compliance_status',
]);
});
}
};

View File

@@ -1,25 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class AddCompoundIndexToPosTransactions extends Migration
{
public function up(): void
{
Schema::table('pos_transactions', function (Blueprint $table) {
// Compound index for the updateOrCreate lookup pattern used in PosController::addItem
$table->index(['pos_session_id', 'product_id'], 'pos_tx_session_product_idx');
});
}
public function down(): void
{
Schema::table('pos_transactions', function (Blueprint $table) {
$table->dropIndex('pos_tx_session_product_idx');
});
}
}

View File

@@ -1,57 +0,0 @@
<?php
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('cooperative_members', function (Blueprint $table) {
if (!Schema::hasColumn('cooperative_members', 'membership_type')) {
$table->string('membership_type')->nullable()->after('role');
}
if (!Schema::hasColumn('cooperative_members', 'membership_level')) {
$table->string('membership_level')->nullable()->after('membership_type');
}
if (!Schema::hasColumn('cooperative_members', 'officer_position')) {
$table->string('officer_position')->nullable()->after('membership_level');
}
if (!Schema::hasColumn('cooperative_members', 'officer_level')) {
$table->string('officer_level')->nullable()->after('officer_position');
}
if (!Schema::hasColumn('cooperative_members', 'concurrent_position')) {
$table->string('concurrent_position')->nullable()->after('officer_level');
}
if (!Schema::hasColumn('cooperative_members', 'concurrent_level')) {
$table->string('concurrent_level')->nullable()->after('concurrent_position');
}
if (!Schema::hasColumn('cooperative_members', 'cooperative_name_alt')) {
$table->string('cooperative_name_alt')->nullable()->after('organization_id');
}
if (!Schema::hasColumn('cooperative_members', 'cooperative_position')) {
$table->string('cooperative_position')->nullable()->after('cooperative_name_alt');
}
if (!Schema::hasColumn('cooperative_members', 'year_beginning')) {
$table->string('year_beginning')->nullable()->after('cooperative_position');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cooperative_members', function (Blueprint $table) {
$table->dropColumn([
'membership_type', 'membership_level', 'officer_position', 'officer_level',
'concurrent_position', 'concurrent_level', 'cooperative_name_alt', 'cooperative_position', 'year_beginning'
]);
});
}
};

View File

@@ -1,37 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('store_managers', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('store_id');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
// Foreign keys
$table->foreign('store_id')->references('id')->on('str')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('store_managers');
}
};

View File

@@ -1,38 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class CreateGroupsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('groups', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('name');
$table->string('type'); // e.g., COOPERATIVE, ASSOCIATION, NGO
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->timestamps();
$table->index('created_by');
$table->index('updated_by');
$table->index('type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('groups');
}
}

View File

@@ -1,41 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class CreateGroupMembersTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('group_members', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('group_id');
$table->unsignedBigInteger('user_id');
$table->string('role')->default('MEMBER');
$table->string('membership_type')->nullable();
$table->json('extra_details')->nullable();
$table->boolean('is_active')->default(true);
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->timestamps();
$table->foreign('group_id')->references('id')->on('groups')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->index('created_by');
$table->index('updated_by');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('group_members');
}
}

View File

@@ -1,37 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cooperative_resolutions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->bigInteger('organization_id')->index();
$table->string('title');
$table->text('description')->nullable();
$table->date('date_approved')->nullable();
$table->string('document_url')->nullable();
$table->enum('status', ['PROPOSED', 'APPROVED', 'RESCINDED'])->default('PROPOSED');
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->boolean('is_active')->default(true);
$table->datetimes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cooperative_resolutions');
}
};

View File

@@ -1,36 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cooperative_votes', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->bigInteger('resolution_id')->index();
$table->bigInteger('user_id')->index();
$table->enum('vote_cast', ['YES', 'NO', 'ABSTAIN'])->default('ABSTAIN');
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->boolean('is_active')->default(true);
$table->datetimes();
$table->unique(['resolution_id', 'user_id']); // Ensure one vote per member per resolution
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cooperative_votes');
}
};

View File

@@ -1,33 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cooperative_documents', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->foreignId('organization_id')->constrained('organizations')->cascadeOnDelete();
$table->string('file_hashkey', 300); // References file_list.hashkey
$table->string('document_type')->nullable(); // e.g. 'RESOLUTION', 'BYLAWS', 'FINANCIAL', 'OTHERS'
$table->foreignId('created_by')->nullable()->constrained('users');
$table->foreignId('updated_by')->nullable()->constrained('users');
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cooperative_documents');
}
};

View File

@@ -1,29 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('cooperative_documents', function (Blueprint $table) {
$table->string('parent_hashkey', 300)->nullable()->after('hashkey');
$table->integer('version_number')->default(1)->after('parent_hashkey');
$table->text('revision_note')->nullable()->after('document_type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cooperative_documents', function (Blueprint $table) {
$table->dropColumn(['parent_hashkey', 'version_number', 'revision_note']);
});
}
};

View File

@@ -1,39 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('member_ledgers', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->bigInteger('user_id')->index();
$table->bigInteger('organization_id')->index()->nullable(); // Nullable if it's a platform-wide balance
$table->decimal('amount', 15, 2);
$table->string('transaction_type'); // SHARE_CAPITAL, SAVINGS, DIVIDEND, TOP_UP, WITHDRAWAL, PURCHASE
$table->enum('flow', ['IN', 'OUT']);
$table->decimal('balance_after', 15, 2);
$table->text('description')->nullable();
$table->string('reference_id')->nullable(); // e.g., global_transaction hashkey
$table->bigInteger('created_by')->nullable();
$table->bigInteger('updated_by')->nullable();
$table->boolean('is_active')->default(true);
$table->datetimes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('member_ledgers');
}
};

View File

@@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class ExpandCooperativeMembersProgramData extends Migration
{
public function up(): void
{
Schema::table('cooperative_members', function (Blueprint $table) {
// Priority & classification
$table->string('priority_sector')->nullable()->after('year_beginning');
$table->string('common_bond')->nullable()->after('priority_sector'); // Residential/Institutional/Occupational/Associational
$table->json('vulnerability_classifications')->nullable()->after('common_bond'); // IP, PWD, Senior, Solo Parent, OSY, etc.
// Government IDs (cooperative context)
$table->string('philsys_id')->nullable()->after('vulnerability_classifications');
$table->string('sss_number')->nullable()->after('philsys_id');
$table->string('pagibig_number')->nullable()->after('sss_number');
// SLP (Sustainable Livelihood Program)
$table->string('slp_track')->nullable()->after('pagibig_number'); // MD / EF
$table->string('slp_association_name')->nullable()->after('slp_track');
$table->string('listahanan_id')->nullable()->after('slp_association_name');
$table->string('fourtps_household_id')->nullable()->after('listahanan_id');
// TUPAD (DOLE)
$table->string('tupad_category')->nullable()->after('fourtps_household_id'); // Underemployed/Displaced/etc.
$table->string('tupad_insurance_beneficiary_name')->nullable()->after('tupad_category');
$table->string('tupad_insurance_beneficiary_relation')->nullable()->after('tupad_insurance_beneficiary_name');
// OSEC / NSRP Employment
$table->string('preferred_occupation')->nullable()->after('tupad_insurance_beneficiary_relation');
$table->json('nsrp_skills')->nullable()->after('preferred_occupation'); // Array of skill strings
$table->string('employment_status')->nullable()->after('nsrp_skills'); // Employed/Underemployed/Unemployed
// Program flags
$table->json('program_participation')->nullable()->after('employment_status'); // ['SLP','TUPAD','OSEC',...]
});
}
public function down(): void
{
Schema::table('cooperative_members', function (Blueprint $table) {
$table->dropColumn([
'priority_sector', 'common_bond', 'vulnerability_classifications',
'philsys_id', 'sss_number', 'pagibig_number',
'slp_track', 'slp_association_name', 'listahanan_id', 'fourtps_household_id',
'tupad_category', 'tupad_insurance_beneficiary_name', 'tupad_insurance_beneficiary_relation',
'preferred_occupation', 'nsrp_skills', 'employment_status', 'program_participation',
]);
});
}
}

View File

@@ -1,17 +0,0 @@
<?php
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
DB::statement('ALTER TABLE cooperative_members MODIFY COLUMN priority_sector JSON NULL');
}
public function down(): void
{
DB::statement('ALTER TABLE cooperative_members MODIFY COLUMN priority_sector VARCHAR(255) NULL');
}
};

View File

@@ -1,29 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::create('org_str', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('organization_id');
$table->unsignedBigInteger('store_id');
$table->timestamps();
$table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade');
$table->foreign('store_id')->references('id')->on('str')->onDelete('cascade');
$table->unique(['organization_id', 'store_id']);
$table->index('organization_id');
$table->index('store_id');
});
}
public function down(): void
{
Schema::dropIfExists('org_str');
}
};

View File

@@ -1,32 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::create('main_organizations', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('organization_id');
$table->string('role')->comment('cooperative, ngo, corporation, sponsor, etc.');
$table->unsignedSmallInteger('priority')->default(0)->comment('0 = primary; higher values = secondary mains in same role');
$table->boolean('is_active')->default(true);
$table->json('metadata')->nullable()->comment('display name overrides, branding, tagline');
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->timestamps();
$table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade');
$table->index(['role', 'is_active']);
$table->index('organization_id');
$table->unique(['role', 'priority', 'is_active'], 'main_orgs_role_priority_active_unique');
});
}
public function down(): void
{
Schema::dropIfExists('main_organizations');
}
};

View File

@@ -1,23 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::table('accounts', function (Blueprint $table) {
$table->string('theme_key')->nullable()->index()->after('description');
$table->string('theme_account_code')->nullable()->index()->after('theme_key');
});
}
public function down(): void
{
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn(['theme_key', 'theme_account_code']);
});
}
};

View File

@@ -1,31 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hypervel\Support\Facades\DB;
return new class extends Migration {
public function up(): void
{
Schema::table('accounts', function (Blueprint $table) {
$table->string('default_flow', 16)->nullable()->index()->after('type');
});
// Backfill existing rows from the old hardcoded rule so behavior is unchanged.
DB::table('accounts')
->whereIn('type', ['Revenue', 'REVENUE', 'Liability', 'LIABILITY'])
->update(['default_flow' => 'INCOME']);
DB::table('accounts')
->whereNull('default_flow')
->update(['default_flow' => 'EXPENSE']);
}
public function down(): void
{
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn('default_flow');
});
}
};

View File

@@ -1,35 +0,0 @@
<?php
use Hyperf\Database\Schema\Blueprint;
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
// Scope accounts to a specific store (NULL = global / Big-3 managed)
Schema::table('accounts', function (Blueprint $table) {
$table->unsignedBigInteger('store_id')->nullable()->index()->after('parent_id');
$table->foreign('store_id')->references('id')->on('str')->nullOnDelete();
});
// Add missing columns referenced by AccountingController / AccountTransaction model
Schema::table('account_transactions', function (Blueprint $table) {
$table->string('flow', 16)->nullable()->index()->after('amount');
$table->string('notes', 500)->nullable()->after('flow');
});
}
public function down(): void
{
Schema::table('account_transactions', function (Blueprint $table) {
$table->dropColumn(['flow', 'notes']);
});
Schema::table('accounts', function (Blueprint $table) {
$table->dropForeign(['store_id']);
$table->dropColumn('store_id');
});
}
};

View File

@@ -1,98 +0,0 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::create('subscription_plans', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->string('name')->index();
$table->string('description')->nullable();
$table->decimal('price', 15, 2)->default(0);
$table->unsignedInteger('duration_days')->default(30);
// 'restrict' | 'warn' | 'auto_deduct'
$table->string('expiry_action')->default('warn');
$table->boolean('active')->default(true)->index();
$table->json('additional_details')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
Schema::create('subscriptions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('plan_id');
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->foreign('plan_id')->references('id')->on('subscription_plans')->cascadeOnDelete();
// 'active' | 'expired' | 'cancelled' | 'pending'
$table->string('status')->default('pending')->index();
$table->dateTime('starts_at')->nullable();
$table->dateTime('expires_at')->nullable()->index();
// 'wallet' | 'gcash' | 'paymaya' — extensible for future gateways
$table->string('payment_method')->default('wallet');
$table->json('additional_details')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
Schema::create('subscription_invoices', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('hashkey', 300)->unique();
$table->unsignedBigInteger('subscription_id');
$table->unsignedBigInteger('user_id')->index();
$table->foreign('subscription_id')->references('id')->on('subscriptions')->cascadeOnDelete();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->decimal('amount', 15, 2)->default(0);
// 'pending' | 'paid' | 'failed'
$table->string('status')->default('pending')->index();
$table->dateTime('paid_at')->nullable();
// 'wallet' | 'gcash' | 'paymaya'
$table->string('payment_method')->default('wallet');
// external gateway transaction ID, QR reference, etc.
$table->string('payment_reference')->nullable()->index();
$table->json('additional_details')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->foreign('created_by')->references('id')->on('users')->nullOnDelete();
$table->foreign('updated_by')->references('id')->on('users')->nullOnDelete();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('subscription_invoices');
Schema::dropIfExists('subscriptions');
Schema::dropIfExists('subscription_plans');
}
};

View File

@@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Facades\Schema;
use Hypervel\Support\Str;
class AddDefaultOrgTypeSystemSetting extends Migration
{
public function up(): void
{
$exists = \DB::table('system_settings')->where('key', 'default_org_type')->exists();
if (!$exists) {
\DB::table('system_settings')->insert([
'hashkey' => (string) Str::uuid() . Str::random(100),
'key' => 'default_org_type',
'value' => 'COOPERATIVE',
'type' => 'select',
'options' => json_encode(['COOPERATIVE', 'NGO', 'CORPORATION']),
'group' => 'general',
'label' => 'Default Organization Type',
'description' => 'Pre-selected type when creating a new organization. Options: Cooperative, NGO, Corporation/Company.',
'created_at' => now(),
'updated_at' => now(),
]);
}
}
public function down(): void
{
\DB::table('system_settings')->where('key', 'default_org_type')->delete();
}
}

View File

@@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Str;
class AddBibleVerseSystemSettings extends Migration
{
public function up(): void
{
if (!\DB::table('system_settings')->where('key', 'bible_verse_text')->exists()) {
\DB::table('system_settings')->insert([
'hashkey' => (string) Str::uuid() . Str::random(100),
'key' => 'bible_verse_text',
'value' => '',
'type' => 'textarea',
'group' => 'content',
'label' => 'Bible Verse of the Day',
'description' => 'The verse text displayed on the homepage for all users. Leave empty to hide.',
'created_at' => now(),
'updated_at' => now(),
]);
}
if (!\DB::table('system_settings')->where('key', 'bible_verse_reference')->exists()) {
\DB::table('system_settings')->insert([
'hashkey' => (string) Str::uuid() . Str::random(100),
'key' => 'bible_verse_reference',
'value' => '',
'type' => 'text',
'group' => 'content',
'label' => 'Bible Verse Reference',
'description' => 'The book, chapter, and verse (e.g. "John 3:16 NIV").',
'created_at' => now(),
'updated_at' => now(),
]);
}
}
public function down(): void
{
\DB::table('system_settings')->whereIn('key', ['bible_verse_text', 'bible_verse_reference'])->delete();
}
}

View File

@@ -1,25 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::table('chapters', function (Blueprint $table) {
$table->unsignedBigInteger('cooperative_id')->nullable()->after('name');
$table->foreign('cooperative_id')->references('id')->on('organizations')->nullOnDelete();
$table->index('cooperative_id');
});
}
public function down(): void
{
Schema::table('chapters', function (Blueprint $table) {
$table->dropForeign(['cooperative_id']);
$table->dropIndex(['cooperative_id']);
$table->dropColumn('cooperative_id');
});
}
};

View File

@@ -1,22 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
Schema::table('chapter_members', function (Blueprint $table) {
$table->string('role')->nullable()->after('position')
->comment('Officer role: PRESIDENT, VICE_PRESIDENT, SECRETARY, TREASURER, AUDITOR, BOARD_MEMBER, MEMBER');
});
}
public function down(): void
{
Schema::table('chapter_members', function (Blueprint $table) {
$table->dropColumn('role');
});
}
};