Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanhooft committed Jan 6, 2025
1 parent 9f69805 commit 2e176c6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions database/migrations/create_order_items_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ return new class extends Migration
$table->integer('unit_price');
$table->decimal('tax_percentage', 6, 4);
$table->unsignedBigInteger('order_id')->nullable();
$table->text('metadata')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/migrations/create_orders_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ return new class extends Migration
$table->string('mollie_payment_id')->nullable();
$table->string('mollie_payment_status', 16)->nullable();
$table->datetime('processed_at')->nullable();
$table->text('metadata')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/migrations/create_refund_items_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ return new class extends Migration
$table->unsignedInteger('quantity');
$table->integer('unit_price');
$table->decimal('tax_percentage', 6, 4);
$table->text('metadata')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/migrations/create_refunds_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ return new class extends Migration
$table->string('mollie_refund_status');
$table->integer('total');
$table->string('currency', 3);
$table->text('metadata')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/migrations/create_subscriptions_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ return new class extends Migration
$table->datetime('cycle_started_at');
$table->datetime('cycle_ends_at')->nullable();
$table->unsignedBigInteger('scheduled_order_item_id')->nullable();
$table->text('metadata')->nullable();
$table->timestamps();
});
}
Expand Down
26 changes: 24 additions & 2 deletions database/migrations/upgrade_to_cashier_v3.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
const METADATA_FIELD_TABLES = [
'orders',
'order_items',
'refunds',
'refund_items',
'subscriptions',
];

/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
//
$this->addMetadataFieldToTables(self::METADATA_FIELD_TABLES);
}

/**
Expand All @@ -23,6 +31,20 @@ return new class extends Migration
*/
public function down(): void
{
//
$this->dropMetadataFieldFromTables(self::METADATA_FIELD_TABLES);
}

protected function addMetadataFieldToTables(array $tables): void
{
collect($tables)->each(fn($table) => Schema::table($table, function (Blueprint $table) {
$table->text('metadata')->nullable();
}));
}

protected function dropMetadataFieldFromTables(array $tables): void
{
collect($tables)->each(fn($table) => Schema::table($table, function (Blueprint $table) {
$table->dropColumn('metadata');
}));
}
};

0 comments on commit 2e176c6

Please sign in to comment.