@extends('backend.layouts.app') @section('title', 'Migration Generator') @section('content')

Migration Generator

Define columns and modifiers, then generate and run a Laravel migration file instantly.

Back to ArtisanGen

How it works

  • Enter a Table Name (e.g. products).
  • Type your fields as name:type, separated by commas. Add modifiers after additional colons: name:type:modifier1:modifier2(value).
  • Enter a Primary Key name. Default is id. If you add a field with the same name as the Primary Key, that field will be used instead.
  • Click Preview to review, Generate to save, then Run Migration to execute it.

string, text, longText, integer, bigInteger, smallInteger, tinyInteger, boolean, decimal(8, 2), float(8, 2), double(8, 2), char(36), date, dateTime, timestamp, json, jsonb, enum(['draft','published']), set(['a','b']), binary, uuid, foreignId.

nullable, unsigned, unique, index, primary, default(value), comment('text'), first, after('column'), useCurrent, charset('utf8mb4'), collation('utf8mb4_unicode_ci'), constrained('users'), cascadeOnDelete, nullOnDelete.

Products name:string, slug:string:unique, price:decimal(8, 2), stock:integer:default(0), category_id:foreignId:constrained('categories'):cascadeOnDelete
Blog Posts title:string, slug:string:unique, content:longText, status:enum(['draft','published']):default('draft'), author_id:foreignId:constrained('users'):cascadeOnDelete
Users name:string, email:string:unique, email_verified_at:datetime:nullable, password:string:nullable, role:string:default('user')
Orders order_number:string:unique, user_id:foreignId:constrained('users'):cascadeOnDelete, total:decimal(8, 2):default(0), status:string:default('pending')

Configure Migration

@csrf

Use lowercase, plural, snake_case. Examples: products, order_items, backend_products. Spaces and dashes will become underscores.

Default is id. Add a matching field to override the auto-generated $table->id().

Format: fieldName:fieldType or fieldName:fieldType(params):modifier:modifier(value). Separate fields with commas.

@push('scripts') @endpush @endsection