Skip to content

BpmMigration - Changelog

Riwayat versi untuk BPM Migration

v0.4.1 (2025-12-23)

TL;DR

Perubahan:

  • 🔥 Breaking: foreignFor*() signatures changed (Breaking) - Parameter $column dihapus
  • ✨ Stub reorganization (High) - Separate CREATE vs ALTER stubs
  • 🔧 Command improvements (Medium) - Auto-detect CREATE/ALTER operations
  • 📝 Internal refactoring (Low) - Better code organization

Impact: 🔴 Breaking: 1 | 🟡 High: 1 | 🟢 Medium: 1 | 🔵 Low: 1

Backward Compatible: ❌ Tidak


🔴 Breaking Changes

foreignFor*() Methods: Removed $column Parameter

Parameter $column telah dihapus dari semua foreignFor*() methods karena bertentangan dengan tujuan auto-discovery. Jika column name di-override secara manual, parameter Model menjadi tidak berguna karena discovery-nya diabaikan.

Rasionale: Method foreignFor() dirancang untuk auto-discovery berdasarkan Model traits (HasUlids/HasUuids). Memberikan opsi override column name membuat parameter Model menjadi redundant dan membingungkan intent dari method.

php
// ❌ v0.4.0 - Parameter bertentangan
$table->foreignFor(Product::class, 'custom_name');
// ^ Discovery dari Model    ^ Mengabaikan discovery

// ✅ v0.4.1 - Intent jelas: discovery
$table->foreignFor(Product::class);
// → Menghasilkan: product_id (auto-derived dari table name)

Fix untuk custom column names:

php
// Opsi 1: Gunakan foreignTable*() explicit methods
$table->foreignTableUlid('products', 'custom_product_id');

// Opsi 2: Manual setup (full control)
$table->char('custom_product_id', 26);
$table->foreign('custom_product_id')
    ->references('id')
    ->on('products');

// Opsi 3: Gunakan constrainedFor() macro
$table->foreignUlid('custom_product_id')
    ->constrainedFor(Product::class);

Affected methods:

  • foreignFor() - Signature: (string|Model $related, ?string $column = null)(string|Model $related)
  • foreignForId() - Signature: (string|Model $related, ?string $column = null)(string|Model $related)
  • foreignForUlid() - Signature: (string|Model $related, ?string $column = null, int $length = 26)(string|Model $related, int $length = 26)
  • foreignForUuid() - Signature: (string|Model $related, ?string $column = null)(string|Model $related)

Catatan: Method foreignTable*() (preset dengan constraint) tetap mendukung parameter $column untuk custom names.


🟡 High Impact

Reorganisasi Stub Files

Stub files direorganisasi ke dalam subdirektori create/ dan alter/ dengan penambahan dedicated stub untuk table alteration. Command sekarang auto-detect operasi CREATE vs ALTER dan menggunakan stub yang sesuai.

Catatan: Stubs adalah internal library dan tidak di-publish ke project user.


🟢 Medium Impact

Peningkatan:

  • Command bpm:make:migration auto-detect CREATE vs ALTER operation
  • Warning jika --int atau --disable-soft-delete digunakan untuk ALTER migrations

🔵 Low Impact

Perubahan internal:

  • Refactoring BpmBlueprint internal helpers untuk DRY code
  • Penambahan helper methods: createActorColumn(), dropActorColumn(), createForeignForColumn()
  • Rename protected methods untuk konsistensi: foreignTablePresetDiscovery(), foreignTablePresetExplicit()
  • Better error messages dengan InvalidArgumentException untuk invalid Model classes
  • Improved PHPDoc documentation

Upgrade

bash
composer update bpmlib/bpm-migration

Breaking changes: 1 item - update foreignFor*() calls

Migration steps:

  1. Search and replace foreignFor*() usage:
bash
# Find usage
grep -r "foreignFor" database/migrations/

# Check if any have 2nd parameter (column name)
grep -r "foreignFor.*,.*)" database/migrations/
  1. Update affected code:
php
// Before (v0.4.0)
$table->foreignFor(Product::class, 'main_product_id');

// After (v0.4.1) - Option A: Use foreignTable*()
$table->foreignTableUlid(Product::class, 'main_product_id');

// After (v0.4.1) - Option B: Manual
$table->foreignUlid('main_product_id')->constrainedFor(Product::class);

Estimated time: 5-15 minutes per project (depending on usage)

Rollback: Downgrade ke v0.4.0 jika diperlukan:

bash
composer require bpmlib/bpm-migration:^0.4.0

v0.4.0 (2025-12-22)

TL;DR

Perubahan:

  • ✨ Foreign Key Helper Methods (High) - 14 methods baru untuk relationship management
  • 📝 BpmBlueprint enhancement (High) - Auto-detection tipe primary key dari Model

Impact: 🟡 High: 1 | 🔵 Low: 0

Backward Compatible: ✅ Ya


🟡 High Impact

Foreign Key Helper Methods

BpmBlueprint sekarang menyediakan 14 foreign key methods dengan auto-detection tipe primary key dari Model traits dan support untuk Model classes, mengeliminasi mismatch antara Model dan migration serta mengurangi boilerplate code untuk relationship management.

Poin utama:

  • Auto-detection dari Model traits (HasUlids/HasUuids)
  • 4 primitive methods (chainable, flexible)
  • 10 preset methods (opinionated, quick setup)
  • Model support (string|Model)

Lihat: BpmBlueprint Foreign Key Methods dan Examples 17-18

Primitive Methods (Chainable):

  • foreignFor() - Auto-detect type, no constraint
  • foreignForId() - Force BIGINT
  • foreignForUlid() - Force ULID
  • foreignForUuid() - Force UUID

Preset Methods (Opinionated):

  • foreignTable() / foreignTableNullable() - Auto-detect + constraint
  • foreignTableId() / foreignTableIdNullable() - BIGINT + constraint
  • foreignTableUlid() / foreignTableUlidNullable() - ULID + constraint
  • foreignTableUuid() / foreignTableUuidNullable() - UUID + constraint

Upgrade

bash
composer update bpmlib/bpm-migration

Breaking changes: Tidak ada

Opsional: Gunakan foreign key methods untuk relationship:

php
// Cara lama masih bekerja
$table->foreignId('product_id')->constrained();

// Cara baru - Auto-detect (opsional)
$table->foreignFor(Product::class)->constrained();

// Atau preset untuk quick setup
$table->foreignTable(Product::class);

v0.3.0 (2025-12-22)

TL;DR

Perubahan:

  • ✨ BpmSchema Model Support (High) - Terima Model instances/classes di schema operations
  • 📝 Perbaikan PHPDoc (Low) - Dukungan IDE lebih baik

Impact: 🟡 High: 1 | 🔵 Low: 1

Backward Compatible: ✅ Ya


🟡 High Impact

BpmSchema Model Support

Method BpmSchema sekarang menerima Model instances atau class names selain string, memberikan type safety dan integrasi IDE yang lebih baik. Alih-alih risiko typo dengan string table name, kamu sekarang bisa menggunakan Model classes yang bisa di-autocomplete dan divalidasi oleh IDE.

Poin utama:

  • Type-safe schema operations
  • IDE autocomplete mencegah typo
  • Bekerja dengan dynamic table names

Lihat: BpmSchema API Reference dan Example 16


🔵 Low Impact

Perubahan:

  • Menambahkan PHPDoc komprehensif ke BpmSchema class

Upgrade

bash
composer update bpmlib/bpm-migration

Breaking changes: Tidak ada

Opsional: Mulai gunakan Model classes di schema operations:

php
// Cara lama masih bekerja
BpmSchema::table('products', ...);

// Cara baru (opsional)
BpmSchema::table(Product::class, ...);

v0.2.0 (2025-12-22)

TL;DR

Perubahan:

  • ✨ Artisan Commands (High) - Scaffold migrations dan models
  • 📦 Service Provider updated (Low) - Auto-register commands

Impact: 🟡 High: 2 | 🔵 Low: 1

Backward Compatible: ✅ Ya


🟡 High Impact

Artisan Command: bpm:make:migration

Generate BPM-style migrations dengan automatic stub selection berdasarkan preferensi kamu (ULID vs INT, with/without soft deletes), mengeliminasi boilerplate dan memastikan konsistensi di seluruh project.

Poin utama:

  • 4 stub variants (ULID/INT × Soft/NoSoft)
  • Auto-select berdasarkan options
  • Generate migrations siap BpmSchema

Lihat: Artisan Commands dan Example 13

Artisan Command: bpm:make:model

Generate Eloquent models dengan BPM traits (HasUlids, SoftDeletes) dan opsional buat migration bersamaan, dengan Laravel 12 observer support menggunakan modern attribute syntax.

Poin utama:

  • Auto-include HasUlids dan SoftDeletes
  • Optional migration generation
  • Laravel 12 observer attributes

Lihat: Artisan Commands dan Examples 14-15


🔵 Low Impact

Perubahan:

  • Service Provider register commands baru secara otomatis

Upgrade

bash
composer update bpmlib/bpm-migration

Breaking changes: Tidak ada

Verifikasi commands:

bash
php artisan list | grep bpm

Opsional: Gunakan commands untuk migrations/models baru