feat: Add customer notes functionality and enhance invoice/order models with date fields
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// ponytail: raw SQL for the column type change — this repo doesn't have doctrine/dbal installed
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('note', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('service_id')->nullable()->index()->after('customer_id');
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE note MODIFY note LONGTEXT NULL');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('note', function (Blueprint $table) {
|
||||
$table->dropColumn('service_id');
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE note MODIFY note VARCHAR(255) NULL');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
// ponytail: raw SQL for the column type change — this repo doesn't have doctrine/dbal installed
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE note MODIFY note LONGTEXT NULL');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE note MODIFY note TEXT NULL');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->date('date')->nullable()->after('invoice_number');
|
||||
});
|
||||
|
||||
// Backfill: ngày lập = ngày tạo, cho các hóa đơn đã có sẵn.
|
||||
DB::statement('UPDATE invoices SET date = DATE(created_at) WHERE date IS NULL');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('date');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->date('date')->nullable()->after('order_num');
|
||||
});
|
||||
|
||||
// Backfill: ngày đặt = ngày tạo, cho các đơn hàng đã có sẵn.
|
||||
DB::statement('UPDATE orders SET date = DATE(created_at) WHERE date IS NULL');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn('date');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user