Rework payment tables, enable payment editing
This commit is contained in:
56
database/migrations/2021_07_23_164158_rework_payments.php
Normal file
56
database/migrations/2021_07_23_164158_rework_payments.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ReworkPayments extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('ab_payment_item', function (Blueprint $table) {
|
||||
$table->dropUnique('UNIQUE');
|
||||
$table->dropForeign('fk_pi_pay');
|
||||
$table->dropPrimary(['id','payment_id','site_id']);
|
||||
$table->dropIndex('fk_pi_pay_idx');
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE ab_payment_item RENAME TO payment_items');
|
||||
|
||||
|
||||
Schema::table('ab_payment', function (Blueprint $table) {
|
||||
$table->dropPrimary(['id','checkout_id','account_id','site_id']);
|
||||
$table->dropUnique('UNIQUE');
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE ab_payment RENAME TO payments');
|
||||
|
||||
DB::statement('ALTER TABLE payment_items ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment');
|
||||
DB::statement('ALTER TABLE payments ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment');
|
||||
DB::statement('ALTER TABLE payments RENAME COLUMN date_payment TO payment_date');
|
||||
|
||||
Schema::table('payment_items', function (Blueprint $table) {
|
||||
$table->unique(['site_id','payment_id','invoice_id']);
|
||||
$table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments');
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->unique(['site_id','id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
abort(500,'cant go back');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user