Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Migrations
fluttersdk/magic-starter-laravel
cursor
migrations
schema
uuid
foreign-keys
morph-columns
migration-helpers

Migrations

Install
php artisan boost:add-skill fluttersdk/magic-starter-laravel

Save this content to: .cursor/rules/migrations.md

# Migrations

- Use anonymous class syntax: `return new class extends Migration { ... }`
- Idempotency: wrap `Schema::create()` in `if (! Schema::hasTable('table_name'))` check
- Primary keys: `MigrationHelper::primaryKey($table)` — never raw `$table->id()` or `$table->uuid()`
  - The one table keyed by a UUID in both modes is `notifications`, whose id is always `$table->uuid('id')->primary()`, because Laravel's `database` channel writes the notification's own UUID there and an integer key refuses every insert. Its `notifiable` morph columns still follow `use_uuids`; `rekey_notifications_table_by_uuid` repairs a table built before this.
- Foreign keys: `MigrationHelper::foreignKey($table, 'user_id')->constrained()->cascadeOnDelete()`
- Morph columns: `MigrationHelper::morphColumns($table, 'notifiable')` — handles UUID/int polymorphism
- String fields: use explicit max length (`string('field', 255)`)
- `profile_photo_path`: 2048 chars max (filesystem paths can be long)
- `phone_country`: `char(2)` fixed width (ISO 3166-1 alpha-2)
- Always include `$table->timestamps()` on entity tables
- Default migrations always published; feature migrations conditional per feature flag

Migrations

  • Use anonymous class syntax: return new class extends Migration { ... }
  • Idempotency: wrap Schema::create() in if (! Schema::hasTable('table_name')) check
  • Primary keys: MigrationHelper::primaryKey($table) — never raw $table->id() or $table->uuid()
    • The one table keyed by a UUID in both modes is notifications, whose id is always $table->uuid('id')->primary(), because Laravel's database channel writes the notification's own UUID there and an integer key refuses every insert. Its notifiable morph columns still follow use_uuids; rekey_notifications_table_by_uuid repairs a table built before this.
  • Foreign keys: MigrationHelper::foreignKey($table, 'user_id')->constrained()->cascadeOnDelete()
  • Morph columns: MigrationHelper::morphColumns($table, 'notifiable') — handles UUID/int polymorphism
  • String fields: use explicit max length (string('field', 255))
  • profile_photo_path: 2048 chars max (filesystem paths can be long)
  • phone_country: char(2) fixed width (ISO 3166-1 alpha-2)
  • Always include $table->timestamps() on entity tables
  • Default migrations always published; feature migrations conditional per feature flag
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus