fxi first test round
This commit is contained in:
@@ -12,6 +12,7 @@ return new class extends Migration
|
||||
Schema::create('schools', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->default('Default School');
|
||||
$table->string('code')->nullable()->unique();
|
||||
$table->string('domain_profile')->default('standard_school');
|
||||
$table->string('timezone')->default('UTC');
|
||||
$table->string('locale')->default('en');
|
||||
|
||||
+70
-1
@@ -7,6 +7,75 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('invoices')) {
|
||||
Schema::create('invoices', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('school_id')->index();
|
||||
$table->unsignedBigInteger('student_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('guardian_id')->nullable()->index();
|
||||
$table->string('currency', 3)->default('USD');
|
||||
$table->integer('total_amount_minor')->default(0);
|
||||
$table->integer('paid_amount_minor')->default(0);
|
||||
$table->integer('balance_amount_minor')->default(0);
|
||||
$table->string('status')->default('draft')->index();
|
||||
$table->date('due_date')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('void_reason')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('invoice_items')) {
|
||||
Schema::create('invoice_items', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('school_id')->index();
|
||||
$table->unsignedBigInteger('invoice_id')->index();
|
||||
$table->string('description');
|
||||
$table->string('type')->default('charge');
|
||||
$table->integer('amount_minor');
|
||||
$table->string('currency', 3)->default('USD');
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('payments')) {
|
||||
Schema::create('payments', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('school_id')->index();
|
||||
$table->unsignedBigInteger('invoice_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('student_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('guardian_id')->nullable()->index();
|
||||
$table->integer('amount_minor');
|
||||
$table->string('currency', 3)->default('USD');
|
||||
$table->string('payment_method')->default('external');
|
||||
$table->date('payment_date')->nullable()->index();
|
||||
$table->string('reference_number')->nullable()->index();
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('status')->default('recorded')->index();
|
||||
$table->text('reverse_reason')->nullable();
|
||||
$table->string('idempotency_key')->nullable()->index();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['school_id', 'reference_number'], 'payments_school_reference_unique');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('payment_refunds')) {
|
||||
Schema::create('payment_refunds', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('school_id')->index();
|
||||
$table->unsignedBigInteger('invoice_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('payment_id')->index();
|
||||
$table->integer('amount_minor');
|
||||
$table->string('currency', 3)->default('USD');
|
||||
$table->text('reason')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create('finance_audit_logs', function (Blueprint $table): void {
|
||||
$table->id(); $table->unsignedBigInteger('school_id')->index(); $table->string('academic_year_id')->nullable()->index(); $table->string('term_id')->nullable()->index(); $table->unsignedBigInteger('actor_user_id')->index(); $table->json('actor_role_snapshot')->nullable(); $table->string('action')->index(); $table->string('entity_type')->index(); $table->string('entity_id')->index(); $table->json('before_json')->nullable(); $table->json('after_json')->nullable(); $table->string('reason', 1000)->nullable(); $table->string('request_id')->nullable()->index(); $table->string('ip_address')->nullable(); $table->text('user_agent')->nullable(); $table->string('idempotency_key')->nullable()->index(); $table->timestamps(); $table->index(['entity_type','entity_id']);
|
||||
});
|
||||
@@ -19,6 +88,6 @@ return new class extends Migration {
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('finance_idempotency_keys'); Schema::dropIfExists('payment_files'); Schema::dropIfExists('finance_audit_logs');
|
||||
Schema::dropIfExists('finance_idempotency_keys'); Schema::dropIfExists('payment_files'); Schema::dropIfExists('finance_audit_logs'); Schema::dropIfExists('payment_refunds'); Schema::dropIfExists('payments'); Schema::dropIfExists('invoice_items'); Schema::dropIfExists('invoices');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,6 +50,18 @@ return new class extends Migration
|
||||
|
||||
private function indexExists(string $table, string $indexName): bool
|
||||
{
|
||||
if (DB::getDriverName() === 'sqlite') {
|
||||
$indexes = DB::select('PRAGMA index_list('.$table.')');
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
if (($index->name ?? null) === $indexName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$database = DB::getDatabaseName();
|
||||
|
||||
$result = DB::selectOne(
|
||||
|
||||
+12
@@ -22,6 +22,18 @@ return new class extends Migration { public function up(): void
|
||||
|
||||
private function indexExists(string $table, string $indexName): bool
|
||||
{
|
||||
if (DB::getDriverName() === 'sqlite') {
|
||||
$indexes = DB::select('PRAGMA index_list('.$table.')');
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
if (($index->name ?? null) === $indexName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$database = DB::getDatabaseName();
|
||||
|
||||
$result = DB::selectOne(
|
||||
|
||||
+3
-3
@@ -48,11 +48,11 @@ return new class extends Migration
|
||||
|
||||
$table->unsignedBigInteger('school_id');
|
||||
|
||||
$table->string('recipient_type', 64);
|
||||
$table->string('recipient_type', 32);
|
||||
$table->unsignedBigInteger('recipient_id');
|
||||
|
||||
$table->string('channel', 32);
|
||||
$table->string('message_category', 64)->default('general');
|
||||
$table->string('message_category', 32)->default('general');
|
||||
|
||||
$table->boolean('opted_in')->default(true);
|
||||
$table->boolean('quiet_hours_enabled')->default(false);
|
||||
@@ -89,7 +89,7 @@ return new class extends Migration
|
||||
$table->string('status', 32)->default('draft');
|
||||
|
||||
$table->string('channel', 32);
|
||||
$table->string('message_category', 64)->default('general');
|
||||
$table->string('message_category', 32)->default('general');
|
||||
$table->string('language', 16)->default('en');
|
||||
|
||||
$table->string('subject', 191)->nullable();
|
||||
|
||||
Reference in New Issue
Block a user