[{"data":1,"prerenderedAt":255},["ShallowReactive",2],{"page-\u002Fv1\u002Fadapters\u002Flaravel\u002Fmigrations":3},{"id":4,"title":5,"body":6,"description":247,"extension":248,"meta":249,"navigation":250,"path":251,"seo":252,"stem":253,"__hash__":254},"content\u002Fv1\u002Fadapters\u002Flaravel\u002Fmigrations.md","Laravel migrations",{"type":7,"value":8,"toc":241},"minimark",[9,14,23,34,37,42,102,106,109,133,137,170,174,212,223,237],[10,11,13],"h1",{"id":12},"migrations","Migrations",[15,16,17,18,22],"p",{},"Each module owns the tables that persist ",[19,20,21],"strong",{},"its"," Domain. Migrations typically live with the module’s persistence adapter:",[24,25,31],"pre",{"className":26,"code":28,"language":29,"meta":30},[27],"language-text","Ordering\u002FInfrastructure\u002FPersistence\u002FEloquent\u002FMigrations\u002F\n","text","",[32,33,28],"code",{"__ignoreMap":30},[15,35,36],{},"Load them from the module ServiceProvider (path may vary by host convention).",[38,39,41],"h2",{"id":40},"guidelines","Guidelines",[43,44,45,58],"table",{},[46,47,48],"thead",{},[49,50,51,55],"tr",{},[52,53,54],"th",{},"Practice",[52,56,57],{},"Rationale",[59,60,61,70,78,86,94],"tbody",{},[49,62,63,67],{},[64,65,66],"td",{},"Colocate migrations with the owning module",[64,68,69],{},"Bounded context owns its data",[49,71,72,75],{},[64,73,74],{},"Avoid cross-module foreign keys for business joins",[64,76,77],{},"Prevents hidden coupling through the schema",[49,79,80,83],{},[64,81,82],{},"Read peer data via ACL \u002F Events",[64,84,85],{},"Matches Core replaceability",[49,87,88,91],{},[64,89,90],{},"Factories beside Eloquent models",[64,92,93],{},"Test data stays in Infrastructure",[49,95,96,99],{},[64,97,98],{},"Name tables with a clear module prefix when helpful",[64,100,101],{},"Reduces collisions in large hosts",[38,103,105],{"id":104},"ownership-checklist","Ownership checklist",[15,107,108],{},"Before adding a column or FK:",[110,111,112,116,123,130],"ol",{},[113,114,115],"li",{},"Which module’s Domain Entity owns this fact?",[113,117,118,119,122],{},"If another module needs it ",[19,120,121],{},"now"," → ACL, not a cross-module Eloquent relation in Application.",[113,124,125,126,129],{},"If another module reacts ",[19,127,128],{},"later"," → Domain Event with a rich payload.",[113,131,132],{},"If you are tempted to “join everything in one query for Filament” → prefer a read model \u002F ACL query port still owned by the consumer’s Infrastructure.",[38,134,136],{"id":135},"loading-migrations-illustrative","Loading migrations (illustrative)",[24,138,142],{"className":139,"code":140,"language":141,"meta":30,"style":30},"language-php shiki shiki-themes github-light github-dark","\u002F\u002F OrderingServiceProvider::boot\n$this->loadMigrationsFrom(\n    __DIR__ . '\u002F..\u002F..\u002FInfrastructure\u002FPersistence\u002FEloquent\u002FMigrations'\n);\n","php",[32,143,144,152,158,164],{"__ignoreMap":30},[145,146,149],"span",{"class":147,"line":148},"line",1,[145,150,151],{},"\u002F\u002F OrderingServiceProvider::boot\n",[145,153,155],{"class":147,"line":154},2,[145,156,157],{},"$this->loadMigrationsFrom(\n",[145,159,161],{"class":147,"line":160},3,[145,162,163],{},"    __DIR__ . '\u002F..\u002F..\u002FInfrastructure\u002FPersistence\u002FEloquent\u002FMigrations'\n",[145,165,167],{"class":147,"line":166},4,[145,168,169],{},");\n",[38,171,173],{"id":172},"anti-patterns","Anti-patterns",[43,175,176,186],{},[46,177,178],{},[49,179,180,183],{},[52,181,182],{},"Anti-pattern",[52,184,185],{},"Fix",[59,187,188,196,204],{},[49,189,190,193],{},[64,191,192],{},"Shared “god” migrations folder with every module’s tables unlabeled",[64,194,195],{},"Colocate per module",[49,197,198,201],{},[64,199,200],{},"FK from Ordering into Warehouse tables for convenience joins",[64,202,203],{},"ACL \u002F Events; duplicate identifiers as values if needed",[49,205,206,209],{},[64,207,208],{},"Business enums encoded only as DB check constraints with no Domain Enum",[64,210,211],{},"Domain Enum + mapping in Repository",[15,213,214,215,218,219,222],{},"Schema design is a host concern; ",[19,216,217],{},"ownership"," and ",[19,220,221],{},"coupling"," are Core concerns.",[15,224,225,226,231,232,236],{},"Core reference: ",[227,228,230],"a",{"href":229},"\u002Fv1\u002Fcore\u002Fports-and-persistence","Ports & persistence"," · ",[227,233,235],{"href":234},"\u002Fv1\u002Fcore\u002Fcross-module-acl","Cross-module ACL",".",[238,239,240],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":30,"searchDepth":154,"depth":154,"links":242},[243,244,245,246],{"id":40,"depth":154,"text":41},{"id":104,"depth":154,"text":105},{"id":135,"depth":154,"text":136},{"id":172,"depth":154,"text":173},"Per-module migrations, table ownership, and avoiding cross-module foreign keys for business joins.","md",{},true,"\u002Fv1\u002Fadapters\u002Flaravel\u002Fmigrations",{"title":5,"description":247},"v1\u002Fadapters\u002Flaravel\u002Fmigrations","q_mDz9tfF_jXsuMfFgoe8pSYOmCwdYA9HDGIXxlIm2Q",1786241414107]