initial: bootstrap from BukidBountyApp base
This commit is contained in:
61
database/migrations/2023_08_03_000000_create_users_table.php
Normal file
61
database/migrations/2023_08_03_000000_create_users_table.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('fullname')->nullable();
|
||||
$table->string('hashkey', 300)->unique();
|
||||
$table->string('mobile_number');
|
||||
$table->string('landline')->nullable();
|
||||
$table->string('nickname')->nullable();
|
||||
$table->string('username')->unique()->nullable();
|
||||
$table->string('email')->unique()->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->timestamp('mobile_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('acct_type');
|
||||
$table->unsignedBigInteger('total_balance')->default(0);
|
||||
$table->bigInteger('total_credit')->default(0);
|
||||
$table->bigInteger('created_by')->constrained('users', 'id')->nullable();
|
||||
$table->bigInteger('updated_by')->constrained('users', 'id')->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->bigInteger('parentuid')->constrained('users', 'id')->nullable();
|
||||
$table->json('targetuids')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('exec_command')->nullable();
|
||||
$table->json('settings')->nullable();
|
||||
$table->boolean('multiple_logins')->default(false);
|
||||
$table->string('referralcode', 150)->nullable();
|
||||
$table->json('photourl')->nullable();
|
||||
$table->json('logs')->nullable();
|
||||
$table->json('cart')->nullable();
|
||||
$table->json('details')->nullable();
|
||||
$table->json('additional_roles')->json()->nullable();
|
||||
$table->json('denied_roles')->json()->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
89
database/migrations/2025_07_14_062954_create_files_table.php
Normal file
89
database/migrations/2025_07_14_062954_create_files_table.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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('file_content', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('hashkey', 300)->unique();
|
||||
$table->string('filehash', 300)->unique();
|
||||
$table->string('titlename', 2000)->default('');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedBigInteger('size_in_bytes')->default(0);
|
||||
$table->json('details')->nullable();
|
||||
// $table->binary('content');
|
||||
|
||||
if (Schema::getConnection()->getDriverName() === 'pgsql') {
|
||||
$table->binary('content');
|
||||
} else {
|
||||
$table->longText('content');
|
||||
}
|
||||
|
||||
|
||||
$table->text('mimetype')->nullable();
|
||||
$table->text('filelocation')->nullable();
|
||||
// $table->bigInteger('created_by')->constrained('users', 'id')->nullable();
|
||||
// $table->bigInteger('updated_by')->constrained('users', 'id')->nullable();
|
||||
|
||||
$table->foreignId('created_by')
|
||||
->nullable()
|
||||
->constrained('users', 'id')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->foreignId('updated_by')
|
||||
->nullable()
|
||||
->constrained('users', 'id')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('file_list', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->json('useruid_access_list')->nullable();
|
||||
$table->string('hashkey', 300)->unique();
|
||||
|
||||
$table->foreignId('contentuid')
|
||||
->constrained('file_content', 'id')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->string('title', 300)->default('');
|
||||
$table->string('filename', 300)->default('');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('tags', 600)->default('');
|
||||
$table->integer('hidden')->default(0);
|
||||
$table->text('categories')->nullable();
|
||||
|
||||
$table->foreignId('created_by')
|
||||
->nullable()
|
||||
->constrained('users', 'id')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->foreignId('updated_by')
|
||||
->nullable()
|
||||
->constrained('users', 'id')
|
||||
->nullOnDelete();
|
||||
|
||||
$table->json('details')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('file_content');
|
||||
Schema::dropIfExists('file_list');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,240 @@
|
||||
<?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');
|
||||
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('table_logs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('hashkey', 300)->unique();
|
||||
$table->string('table_name')->index();
|
||||
$table->unsignedBigInteger('target_id')->index();
|
||||
|
||||
|
||||
$table->json('original_data')->nullable();
|
||||
$table->json('new_data')->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->timestamps();
|
||||
$table->index(['table_name', 'target_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('table_logs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Hypervel\Database\Migrations\Migration;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hypervel\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('announcements', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->text('content');
|
||||
$table->string('type')->default('info'); // info, success, warning, danger
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamp('starts_at')->nullable();
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('announcements');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('announcements', function (Blueprint $table) {
|
||||
$table->string('hashkey', 300)->unique()->nullable()->after('id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->dropColumn('hashkey');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('announcements', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->after('created_by');
|
||||
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->dropForeign(['updated_by']);
|
||||
$table->dropColumn('updated_by');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Hypervel\Database\Migrations\Migration;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hypervel\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->string('photo')->nullable()->after('content');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->dropColumn('photo');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
76
database/migrations/2026_03_23_000001_create_pos_tables.php
Normal file
76
database/migrations/2026_03_23_000001_create_pos_tables.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hypervel\Database\Migrations\Migration;
|
||||
use Hypervel\Support\Facades\Schema;
|
||||
use Hypervel\Support\Facades\DB;
|
||||
use Hypervel\Support\Str;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_infos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('hashkey', 300)->unique();
|
||||
$table->unsignedBigInteger('user_id')->unique();
|
||||
$table->string('firstname')->nullable();
|
||||
$table->string('middlename')->nullable();
|
||||
$table->string('lastname')->nullable();
|
||||
$table->string('fullname')->nullable();
|
||||
$table->string('landline')->nullable();
|
||||
$table->string('mobile')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('alt_email')->nullable();
|
||||
$table->string('alt_landline')->nullable();
|
||||
$table->string('alt_mobile')->nullable();
|
||||
$table->string('facebook_url')->nullable();
|
||||
$table->json('bank_details')->nullable();
|
||||
$table->json('addresses')->nullable();
|
||||
$table->json('other_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('created_by')->references('id')->on('users')->onDelete('set null');
|
||||
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Backfill existing users
|
||||
$users = DB::table('users')->get();
|
||||
foreach ($users as $user) {
|
||||
DB::table('user_infos')->insert([
|
||||
'hashkey' => Str::uuid()->toString() . Str::random(100),
|
||||
'user_id' => $user->id,
|
||||
'fullname' => $user->fullname ?? $user->name,
|
||||
'email' => $user->email,
|
||||
'mobile' => $user->mobile_number,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_infos');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
34
database/migrations/2026_03_27_123222_create_logs_table.php
Normal file
34
database/migrations/2026_03_27_123222_create_logs_table.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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('logs', function (Blueprint $table) {
|
||||
$table->bigIncrements('uid');
|
||||
$table->string('log_type')->index();
|
||||
$table->string('log_category')->index();
|
||||
$table->text('description')->nullable();
|
||||
$table->json('server_data')->nullable();
|
||||
$table->json('session_data')->nullable();
|
||||
$table->string('useruid')->nullable()->index();
|
||||
$table->timestamp('log_time')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('logs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('db_backups', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('hashkey', 300)->unique();
|
||||
$table->string('file_content_hashkey', 300);
|
||||
$table->string('filename', 300);
|
||||
$table->bigInteger('size_in_bytes');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('created_by')->references('id')->on('users')->onDelete('set null');
|
||||
$table->foreign('updated_by')->references('id')->on('users')->onDelete('set null');
|
||||
// file_content_hashkey is linked to file_content table's hashkey (string)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('db_backups');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('db_backups', function (Blueprint $table) {
|
||||
$table->string('name', 300)->after('hashkey')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('db_backups', function (Blueprint $table) {
|
||||
$table->dropColumn('name');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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::create('system_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique()->index();
|
||||
$table->text('value')->nullable();
|
||||
$table->string('type')->default('text'); // text, image, json, number, boolean
|
||||
$table->string('group')->default('general')->index();
|
||||
$table->string('label')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('hashkey', 300)->unique()->index();
|
||||
$table->string('created_by')->nullable();
|
||||
$table->string('updated_by')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('system_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?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('user_infos', function (Blueprint $table) {
|
||||
// Personal Info
|
||||
if (!Schema::hasColumn('user_infos', 'firstname')) $table->string('firstname')->nullable();
|
||||
if (!Schema::hasColumn('user_infos', 'middlename')) $table->string('middlename')->nullable();
|
||||
if (!Schema::hasColumn('user_infos', 'lastname')) $table->string('lastname')->nullable();
|
||||
$table->string('suffix')->nullable();
|
||||
$table->string('gender')->nullable();
|
||||
$table->date('dob')->nullable();
|
||||
$table->string('priority_sector')->nullable();
|
||||
|
||||
// Social Accounts
|
||||
$table->string('messenger_id')->nullable();
|
||||
$table->string('viber_number')->nullable();
|
||||
$table->string('tiktok_username')->nullable();
|
||||
|
||||
// Address Fragments
|
||||
$table->string('region')->nullable();
|
||||
$table->string('province')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('barangay')->nullable();
|
||||
|
||||
// Family & Education
|
||||
$table->string('civil_status')->nullable();
|
||||
$table->integer('children_count')->default(0);
|
||||
$table->integer('dependent_count')->nullable();
|
||||
$table->string('education_level')->nullable();
|
||||
$table->string('course')->nullable();
|
||||
$table->string('school')->nullable();
|
||||
$table->string('year_last_attended')->nullable();
|
||||
|
||||
// Livelihood
|
||||
$table->string('livelihood_source')->nullable();
|
||||
$table->string('last_company')->nullable();
|
||||
$table->string('employer_name')->nullable();
|
||||
$table->string('last_position')->nullable();
|
||||
$table->string('occupation')->nullable();
|
||||
$table->decimal('monthly_income', 15, 2)->nullable();
|
||||
$table->string('last_employment_year')->nullable();
|
||||
|
||||
// Government Info
|
||||
$table->string('tin')->nullable();
|
||||
$table->string('philhealth_id')->nullable();
|
||||
$table->string('gov_id')->nullable();
|
||||
$table->string('id_type')->nullable();
|
||||
$table->string('id_number')->nullable();
|
||||
$table->string('beneficiary_type')->nullable();
|
||||
|
||||
// Emergency Contact Info
|
||||
$table->string('emergency_contact_name')->nullable();
|
||||
$table->string('emergency_contact_address')->nullable();
|
||||
$table->string('emergency_contact_phone')->nullable();
|
||||
$table->string('emergency_contact_relation')->nullable();
|
||||
$table->integer('emergency_contact_user_id')->nullable();
|
||||
|
||||
// Financial Info
|
||||
$table->string('bank_account_no')->nullable();
|
||||
|
||||
// Note: emergency_contact_user_id is not set as actual FK to avoid issues if the user is deleted
|
||||
// but we'll treat it as such in the model.
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_infos', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'firstname', 'middlename', 'lastname', 'suffix', 'gender', 'dob',
|
||||
'messenger_id', 'viber_number', 'tiktok_username',
|
||||
'region', 'province', 'city', 'barangay',
|
||||
'civil_status', 'children_count', 'education_level', 'course', 'school', 'year_last_attended',
|
||||
'livelihood_source', 'last_company', 'last_position', 'last_employment_year',
|
||||
'tin', 'philhealth_id', 'gov_id', 'id_type', 'id_number', 'beneficiary_type',
|
||||
'priority_sector', 'employer_name', 'occupation', 'monthly_income', 'dependent_count',
|
||||
'bank_account_no',
|
||||
'emergency_contact_name', 'emergency_contact_address', 'emergency_contact_phone', 'emergency_contact_relation', 'emergency_contact_user_id'
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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'
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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('landing_pages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->longText('html_content');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('hashkey', 300)->unique()->index();
|
||||
$table->string('created_by')->nullable();
|
||||
$table->string('updated_by')->nullable();
|
||||
$table->boolean('is_active')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('landing_pages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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
|
||||
{
|
||||
Schema::table('system_settings', function (Blueprint $table) {
|
||||
$table->text('options')->nullable()->after('type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('system_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('options');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
class CreateChaptersTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('chapters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('hashkey')->unique();
|
||||
$table->string('name');
|
||||
$table->enum('level', ['national', 'region', 'province', 'city', 'barangay']);
|
||||
$table->unsignedBigInteger('parent_id')->nullable();
|
||||
$table->string('location_key')->nullable()->comment('Normalized slug for auto-matching UserInfo address fields');
|
||||
$table->decimal('lat', 10, 7)->nullable();
|
||||
$table->decimal('lng', 10, 7)->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('parent_id')->references('id')->on('chapters')->nullOnDelete();
|
||||
$table->index(['level', 'is_active']);
|
||||
$table->index('location_key');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('chapters');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
class CreateChapterMembersTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('chapter_members', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('hashkey')->unique();
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->unsignedBigInteger('chapter_id');
|
||||
$table->string('position')->nullable()->comment('Position title from chapter_positions system setting');
|
||||
$table->boolean('is_manual_override')->default(false)->comment('True if manually assigned, overriding address-based auto-assignment');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedBigInteger('assigned_by')->nullable();
|
||||
$table->timestamp('assigned_at')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
$table->foreign('chapter_id')->references('id')->on('chapters')->cascadeOnDelete();
|
||||
$table->unique(['user_id', 'chapter_id']);
|
||||
$table->index(['chapter_id', 'is_active']);
|
||||
$table->index('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('chapter_members');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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('file_list', function (Blueprint $table) {
|
||||
$table->string('cdn_url', 1024)->nullable()->after('filename');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('file_list', function (Blueprint $table) {
|
||||
$table->dropColumn('cdn_url');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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('file_list', function (Blueprint $table) {
|
||||
$table->boolean('is_public')->default(false)->index()->after('cdn_url');
|
||||
$table->string('file_type', 100)->nullable()->index()->after('is_public');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('file_list', function (Blueprint $table) {
|
||||
$table->dropColumn(['is_public', 'file_type']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Hyperf\Database\Schema\Schema;
|
||||
use Hyperf\Database\Schema\Blueprint;
|
||||
use Hyperf\Database\Migrations\Migration;
|
||||
|
||||
class CreatePersonalAccessTokensTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('token', 64)->unique();
|
||||
$table->json('abilities')->nullable();
|
||||
$table->json('allowed_ips')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->string('last_used_ip', 45)->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('revoked_by')->nullable();
|
||||
$table->timestamp('revoked_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('expires_at');
|
||||
$table->index('revoked_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user