[{"data":1,"prerenderedAt":1250},["ShallowReactive",2],{"navigation":3,"\u002Frecipes\u002Fmigrations":208,"\u002Frecipes\u002Fmigrations-surround":1247},[4,98,175],{"title":5,"path":6,"stem":7,"children":8,"icon":97},"Guide","\u002Fguide","1.guide\u002F1.index",[9,12,17,22,46,61,79],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-house",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fguide\u002Finstallation","1.guide\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Quick start","\u002Fguide\u002Fquick-start","1.guide\u002F3.quick-start","i-lucide-rocket",{"title":23,"path":24,"stem":25,"children":26,"icon":45},"Server","\u002Fguide\u002Fserver","1.guide\u002F4.server\u002F1.index",[27,30,35,40],{"title":28,"path":24,"stem":25,"icon":29},"Usage","i-lucide-server",{"title":31,"path":32,"stem":33,"icon":34},"Config file","\u002Fguide\u002Fserver\u002Fconfig-file","1.guide\u002F4.server\u002F2.config-file","i-lucide-file-cog",{"title":36,"path":37,"stem":38,"icon":39},"Options","\u002Fguide\u002Fserver\u002Foptions","1.guide\u002F4.server\u002F3.options","i-lucide-settings",{"title":41,"path":42,"stem":43,"icon":44},"Advanced","\u002Fguide\u002Fserver\u002Fadvanced","1.guide\u002F4.server\u002F4.advanced","i-lucide-flask-conical",false,{"title":47,"path":48,"stem":49,"children":50,"icon":45},"Client","\u002Fguide\u002Fclient","1.guide\u002F5.client\u002F1.index",[51,53,58],{"title":28,"path":48,"stem":49,"icon":52},"i-lucide-monitor-smartphone",{"title":54,"path":55,"stem":56,"icon":57},"Live queries","\u002Fguide\u002Fclient\u002Flive-queries","1.guide\u002F5.client\u002F2.live-queries","i-lucide-radio",{"title":41,"path":59,"stem":60,"icon":44},"\u002Fguide\u002Fclient\u002Fadvanced","1.guide\u002F5.client\u002F3.advanced",{"title":62,"path":63,"stem":64,"children":65,"icon":45},"Development socket","\u002Fguide\u002Fsocket","1.guide\u002F6.socket\u002F1.index",[66,68,71,74],{"title":28,"path":63,"stem":64,"icon":67},"i-lucide-plug",{"title":36,"path":69,"stem":70,"icon":39},"\u002Fguide\u002Fsocket\u002Foptions","1.guide\u002F6.socket\u002F2.options",{"title":41,"path":72,"stem":73,"icon":44},"\u002Fguide\u002Fsocket\u002Fadvanced","1.guide\u002F6.socket\u002F3.advanced",{"title":75,"path":76,"stem":77,"icon":78},"PGlite in dev, Postgres in prod","\u002Fguide\u002Fsocket\u002Fdevelopment-only","1.guide\u002F6.socket\u002F4.development-only","i-lucide-cloud-upload",{"title":80,"path":81,"stem":82,"children":83,"icon":45},"DevTools & tooling","\u002Fguide\u002Fdevtools","1.guide\u002F7.devtools\u002F1.index",[84,87,92],{"title":85,"path":81,"stem":82,"icon":86},"DevTools tab","i-lucide-wrench",{"title":88,"path":89,"stem":90,"icon":91},"Actions","\u002Fguide\u002Fdevtools\u002Factions","1.guide\u002F7.devtools\u002F2.actions","i-lucide-zap",{"title":93,"path":94,"stem":95,"icon":96},"Terminal","\u002Fguide\u002Fdevtools\u002Fterminal","1.guide\u002F7.devtools\u002F3.terminal","i-lucide-square-terminal","i-lucide-book-open",{"title":99,"icon":100,"path":101,"stem":102,"children":103,"page":45},"Recipes","i-lucide-chef-hat","\u002Frecipes","2.recipes",[104,116,138,159,171],{"title":105,"path":106,"stem":107,"children":108,"icon":45},"Migrations","\u002Frecipes\u002Fmigrations","2.recipes\u002F1.migrations\u002F1.index",[109,111],{"title":28,"path":106,"stem":107,"icon":110},"i-lucide-database-backup",{"title":112,"path":113,"stem":114,"icon":115},"Edited migrations","\u002Frecipes\u002Fmigrations\u002Fedited-migrations","2.recipes\u002F1.migrations\u002F2.edited-migrations","i-lucide-file-diff",{"title":117,"path":118,"stem":119,"children":120,"icon":45},"Testing","\u002Frecipes\u002Ftesting","2.recipes\u002F2.testing\u002F1.index",[121,123,128,133],{"title":28,"path":118,"stem":119,"icon":122},"i-lucide-test-tube",{"title":124,"path":125,"stem":126,"icon":127},"Isolation","\u002Frecipes\u002Ftesting\u002Fisolation","2.recipes\u002F2.testing\u002F2.isolation","i-lucide-git-fork",{"title":129,"path":130,"stem":131,"icon":132},"vitest","\u002Frecipes\u002Ftesting\u002Fvitest","2.recipes\u002F2.testing\u002F3.vitest","i-simple-icons-vitest",{"title":134,"path":135,"stem":136,"icon":137},"@nuxt\u002Ftest-utils","\u002Frecipes\u002Ftesting\u002Fnuxt-test-utils","2.recipes\u002F2.testing\u002F4.nuxt-test-utils","i-simple-icons-nuxt",{"title":139,"path":140,"stem":141,"children":142,"icon":45},"Deploy","\u002Frecipes\u002Fdeploy","2.recipes\u002F3.deploy\u002F1.index",[143,144,149,154],{"title":139,"path":140,"stem":141},{"title":145,"path":146,"stem":147,"icon":148},"Any Postgres","\u002Frecipes\u002Fdeploy\u002Fpostgres","2.recipes\u002F3.deploy\u002F2.postgres","i-lucide-database",{"title":150,"path":151,"stem":152,"icon":153},"Netlify","\u002Frecipes\u002Fdeploy\u002Fnetlify","2.recipes\u002F3.deploy\u002F3.netlify","i-simple-icons-netlify",{"title":155,"path":156,"stem":157,"icon":158},"Neon","\u002Frecipes\u002Fdeploy\u002Fneon","2.recipes\u002F3.deploy\u002F4.neon","i-simple-icons-neon",{"title":160,"path":161,"stem":162,"children":163,"icon":45},"Outside Nuxt","\u002Frecipes\u002Foutside-nuxt","2.recipes\u002F4.outside-nuxt\u002F1.index",[164,167],{"title":165,"path":161,"stem":162,"icon":166},"Config and provider","i-lucide-package",{"title":168,"path":169,"stem":170,"icon":67},"Socket server","\u002Frecipes\u002Foutside-nuxt\u002Fsocket","2.recipes\u002F4.outside-nuxt\u002F2.socket",{"title":172,"path":173,"stem":174,"icon":67},"Nitro's useDatabase","\u002Frecipes\u002Fnitro-database","2.recipes\u002F5.nitro-database",{"title":176,"icon":177,"path":178,"stem":179,"children":180,"page":45},"Reference","i-lucide-code-xml","\u002Freference","3.reference",[181,185,189,193,198,203],{"title":182,"path":183,"stem":184,"icon":34},"Config files","\u002Freference\u002Fconfig-files","3.reference\u002F1.config-files",{"title":186,"path":187,"stem":188,"icon":39},"Module options","\u002Freference\u002Fmodule-options","3.reference\u002F2.module-options",{"title":190,"path":191,"stem":192,"icon":67},"Socket options","\u002Freference\u002Fsocket-options","3.reference\u002F3.socket-options",{"title":194,"path":195,"stem":196,"icon":197},"Exports","\u002Freference\u002Fexports","3.reference\u002F4.exports","i-lucide-boxes",{"title":199,"path":200,"stem":201,"icon":202},"Hooks","\u002Freference\u002Fhooks","3.reference\u002F5.hooks","i-lucide-anchor",{"title":204,"path":205,"stem":206,"icon":207},"Environment","\u002Freference\u002Fenvironment","3.reference\u002F6.environment","i-lucide-variable",{"id":209,"title":105,"body":210,"description":1240,"extension":1241,"links":1242,"meta":1243,"navigation":1244,"path":106,"seo":1245,"stem":107,"__hash__":1246},"docs\u002F2.recipes\u002F1.migrations\u002F1.index.md",{"type":211,"value":212,"toc":1231},"minimark",[213,230,430,447,465,477,482,493,507,641,666,702,709,713,719,763,768,793,966,969,973,984,1052,1061,1064,1159,1168,1191,1195,1220,1227],[214,215,216,217,221,222,225,226,229],"p",{},"A migration history is a folder of SQL files. In development, ",[218,219,220],"code",{},"init"," applies them to PGlite with ",[218,223,224],{},"applyMigrations"," from ",[218,227,228],{},"nuxt-pglite\u002Fmigrations",", so the local database is built from the same files as the production one. In production, either you apply them (from the build command or a CI job), or the platform does, from the files committed with your app.",[231,232,238],"pre",{"className":233,"code":234,"filename":235,"language":236,"meta":237,"style":237},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { fileURLToPath } from 'node:url'\n\nimport { applyMigrations } from 'nuxt-pglite\u002Fmigrations'\n\n\u002F\u002F Absolute, so that it does not depend on where `nuxt dev` is started from.\nconst migrations = fileURLToPath(new URL('.\u002Fdatabase\u002Fmigrations', import.meta.url))\n\nexport default definePGliteServerConfig({\n  init: (pg) => applyMigrations(pg, migrations),\n})\n","server\u002Fpglite.config.ts","ts","",[218,239,240,273,280,300,305,312,364,369,386,421],{"__ignoreMap":237},[241,242,245,249,253,257,260,263,266,270],"span",{"class":243,"line":244},"line",1,[241,246,248],{"class":247},"s7zQu","import",[241,250,252],{"class":251},"sMK4o"," {",[241,254,256],{"class":255},"sTEyZ"," fileURLToPath",[241,258,259],{"class":251}," }",[241,261,262],{"class":247}," from",[241,264,265],{"class":251}," '",[241,267,269],{"class":268},"sfazB","node:url",[241,271,272],{"class":251},"'\n",[241,274,276],{"class":243,"line":275},2,[241,277,279],{"emptyLinePlaceholder":278},true,"\n",[241,281,283,285,287,290,292,294,296,298],{"class":243,"line":282},3,[241,284,248],{"class":247},[241,286,252],{"class":251},[241,288,289],{"class":255}," applyMigrations",[241,291,259],{"class":251},[241,293,262],{"class":247},[241,295,265],{"class":251},[241,297,228],{"class":268},[241,299,272],{"class":251},[241,301,303],{"class":243,"line":302},4,[241,304,279],{"emptyLinePlaceholder":278},[241,306,308],{"class":243,"line":307},5,[241,309,311],{"class":310},"sHwdD","\u002F\u002F Absolute, so that it does not depend on where `nuxt dev` is started from.\n",[241,313,315,319,322,325,328,331,334,337,339,342,345,347,350,353,356,359,361],{"class":243,"line":314},6,[241,316,318],{"class":317},"spNyl","const",[241,320,321],{"class":255}," migrations ",[241,323,324],{"class":251},"=",[241,326,256],{"class":327},"s2Zo4",[241,329,330],{"class":255},"(",[241,332,333],{"class":251},"new",[241,335,336],{"class":327}," URL",[241,338,330],{"class":255},[241,340,341],{"class":251},"'",[241,343,344],{"class":268},".\u002Fdatabase\u002Fmigrations",[241,346,341],{"class":251},[241,348,349],{"class":251},",",[241,351,352],{"class":247}," import",[241,354,355],{"class":251},".",[241,357,358],{"class":255},"meta",[241,360,355],{"class":251},[241,362,363],{"class":255},"url))\n",[241,365,367],{"class":243,"line":366},7,[241,368,279],{"emptyLinePlaceholder":278},[241,370,372,375,378,381,383],{"class":243,"line":371},8,[241,373,374],{"class":247},"export",[241,376,377],{"class":247}," default",[241,379,380],{"class":327}," definePGliteServerConfig",[241,382,330],{"class":255},[241,384,385],{"class":251},"{\n",[241,387,389,392,395,398,402,405,408,410,413,415,418],{"class":243,"line":388},9,[241,390,391],{"class":327},"  init",[241,393,394],{"class":251},":",[241,396,397],{"class":251}," (",[241,399,401],{"class":400},"sHdIc","pg",[241,403,404],{"class":251},")",[241,406,407],{"class":317}," =>",[241,409,289],{"class":327},[241,411,412],{"class":255},"(pg",[241,414,349],{"class":251},[241,416,417],{"class":255}," migrations)",[241,419,420],{"class":251},",\n",[241,422,424,427],{"class":243,"line":423},10,[241,425,426],{"class":251},"}",[241,428,429],{"class":255},")\n",[214,431,432,434,435,439,440,442,443,446],{},[218,433,220],{}," runs once per created instance, the ",[436,437,438],"a",{"href":63},"socket's"," included, so the database is brought up to the files before anything queries it. Each migration runs in its own transaction together with its tracking row, and ",[218,441,224],{}," resolves with the names it applied. Add a migration, restart ",[218,444,445],{},"nuxt dev",", and it is applied.",[214,448,449,450,453,454,457,458,460,461,464],{},"A relative directory is resolved from ",[218,451,452],{},"process.cwd()",", which is why the example builds an absolute one from the config file's location. With the in-process server (",[218,455,456],{},"server.enabled","), ",[218,459,220],{}," also runs in the built app, where the files are not shipped: keep it under ",[218,462,463],{},"$development"," there, or pass a directory that exists at runtime.",[466,467,468],"note",{},[214,469,470,471,474,475,355],{},"The config file is loaded with the app's aliases, so ",[218,472,473],{},"#pglite\u002Fmigrations"," imports the same entry as ",[218,476,228],{},[478,479,481],"h2",{"id":480},"generating-the-files","Generating the files",[214,483,484,485,488,489,492],{},"Any tool that writes plain SQL files works. A migration is either a ",[218,486,487],{},"\u003Cname>\u002Fmigration.sql"," directory or a flat ",[218,490,491],{},"\u003Cname>.sql"," file; anything else in the directory is ignored, and migrations apply in name order.",[214,494,495,496,499,500,503,504,394],{},"drizzle-kit ",[218,497,498],{},"1.0.0-rc.4"," and later writes ",[218,501,502],{},"\u003Ctimestamp>_\u003Cname>\u002Fmigration.sql"," next to a ",[218,505,506],{},"snapshot.json",[231,508,511],{"className":233,"code":509,"filename":510,"language":236,"meta":237,"style":237},"import { defineConfig } from 'drizzle-kit'\n\nexport default defineConfig({\n  schema: '.\u002Fserver\u002Fdatabase\u002Fschema.ts',\n  out: '.\u002Fserver\u002Fdatabase\u002Fmigrations',\n  dialect: 'postgresql',\n  dbCredentials: {\n    \u002F\u002F the development socket, for `studio` and `check` while `nuxt dev` runs\n    url: 'postgres:\u002F\u002Fpostgres@127.0.0.1:5433\u002Fpostgres',\n  },\n})\n","drizzle.config.ts",[218,512,513,533,537,549,566,582,598,608,613,629,634],{"__ignoreMap":237},[241,514,515,517,519,522,524,526,528,531],{"class":243,"line":244},[241,516,248],{"class":247},[241,518,252],{"class":251},[241,520,521],{"class":255}," defineConfig",[241,523,259],{"class":251},[241,525,262],{"class":247},[241,527,265],{"class":251},[241,529,530],{"class":268},"drizzle-kit",[241,532,272],{"class":251},[241,534,535],{"class":243,"line":275},[241,536,279],{"emptyLinePlaceholder":278},[241,538,539,541,543,545,547],{"class":243,"line":282},[241,540,374],{"class":247},[241,542,377],{"class":247},[241,544,521],{"class":327},[241,546,330],{"class":255},[241,548,385],{"class":251},[241,550,551,555,557,559,562,564],{"class":243,"line":302},[241,552,554],{"class":553},"swJcz","  schema",[241,556,394],{"class":251},[241,558,265],{"class":251},[241,560,561],{"class":268},".\u002Fserver\u002Fdatabase\u002Fschema.ts",[241,563,341],{"class":251},[241,565,420],{"class":251},[241,567,568,571,573,575,578,580],{"class":243,"line":307},[241,569,570],{"class":553},"  out",[241,572,394],{"class":251},[241,574,265],{"class":251},[241,576,577],{"class":268},".\u002Fserver\u002Fdatabase\u002Fmigrations",[241,579,341],{"class":251},[241,581,420],{"class":251},[241,583,584,587,589,591,594,596],{"class":243,"line":314},[241,585,586],{"class":553},"  dialect",[241,588,394],{"class":251},[241,590,265],{"class":251},[241,592,593],{"class":268},"postgresql",[241,595,341],{"class":251},[241,597,420],{"class":251},[241,599,600,603,605],{"class":243,"line":366},[241,601,602],{"class":553},"  dbCredentials",[241,604,394],{"class":251},[241,606,607],{"class":251}," {\n",[241,609,610],{"class":243,"line":371},[241,611,612],{"class":310},"    \u002F\u002F the development socket, for `studio` and `check` while `nuxt dev` runs\n",[241,614,615,618,620,622,625,627],{"class":243,"line":388},[241,616,617],{"class":553},"    url",[241,619,394],{"class":251},[241,621,265],{"class":251},[241,623,624],{"class":268},"postgres:\u002F\u002Fpostgres@127.0.0.1:5433\u002Fpostgres",[241,626,341],{"class":251},[241,628,420],{"class":251},[241,630,631],{"class":243,"line":423},[241,632,633],{"class":251},"  },\n",[241,635,637,639],{"class":243,"line":636},11,[241,638,426],{"class":251},[241,640,429],{"class":255},[231,642,646],{"className":643,"code":644,"filename":93,"language":645,"meta":237,"style":237},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npx drizzle-kit generate --name add_visits\n","bash",[218,647,648],{"__ignoreMap":237},[241,649,650,654,657,660,663],{"class":243,"line":244},[241,651,653],{"class":652},"sBMFI","npx",[241,655,656],{"class":268}," drizzle-kit",[241,658,659],{"class":268}," generate",[241,661,662],{"class":268}," --name",[241,664,665],{"class":268}," add_visits\n",[231,667,672],{"className":668,"code":669,"filename":670,"language":671,"meta":237,"style":237},"language-txt shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","20261008032022_init\u002F\n  migration.sql\n  snapshot.json\n20261012093000_add_visits\u002F\n  migration.sql\n  snapshot.json\n","server\u002Fdatabase\u002Fmigrations","txt",[218,673,674,679,684,689,694,698],{"__ignoreMap":237},[241,675,676],{"class":243,"line":244},[241,677,678],{},"20261008032022_init\u002F\n",[241,680,681],{"class":243,"line":275},[241,682,683],{},"  migration.sql\n",[241,685,686],{"class":243,"line":282},[241,687,688],{},"  snapshot.json\n",[241,690,691],{"class":243,"line":302},[241,692,693],{},"20261012093000_add_visits\u002F\n",[241,695,696],{"class":243,"line":307},[241,697,683],{},[241,699,700],{"class":243,"line":314},[241,701,688],{},[214,703,704,705,708],{},"Against the development socket, prefer the files to ",[218,706,707],{},"drizzle-kit push",": a pushed schema is not what production will be built from.",[478,710,712],{"id":711},"in-production","In production",[214,714,715,716,718],{},"The same files reach the real database in one of two ways, depending on your platform. See ",[436,717,139],{"href":140}," for how each fits with the rest of the setup.",[720,721,722,743],"ul",{},[723,724,725,729,730,733,734,737,738,740,741,355],"li",{},[726,727,728],"strong",{},"You apply them",": most hosts only run your build. Run your tool's migrate command with the production ",[218,731,732],{},"DATABASE_URL",", in the build command or a CI job, before the new code goes live: ",[218,735,736],{},"drizzle-kit migrate",", or ",[218,739,224],{}," itself, below. See ",[436,742,145],{"href":146},[723,744,745,748,749,752,753,756,757,760,761,355],{},[726,746,747],{},"The platform applies them",": some platforms apply the SQL files committed with your app on deploy. Point ",[218,750,751],{},"out"," at the directory they read, and never run ",[218,754,755],{},"push"," or ",[218,758,759],{},"migrate"," against their database: the platform records what it applied, and a schema changed behind its back is one the next deploy's migrations run against blindly. See ",[436,762,150],{"href":151},[764,765,767],"h3",{"id":766},"applying-them-yourself","Applying them yourself",[214,769,770,771,774,775,778,779,782,783,786,787,789,790,792],{},"Any database with ",[218,772,773],{},"exec",", ",[218,776,777],{},"query"," and ",[218,780,781],{},"transaction"," works, PGlite as is. ",[218,784,785],{},"fromPool"," adapts a ",[218,788,401],{}," pool, so the files ",[218,791,220],{}," applies locally are applied to Postgres by the same code, with the same bookkeeping:",[231,794,797],{"className":233,"code":795,"filename":796,"language":236,"meta":237,"style":237},"import { Pool } from 'pg'\nimport { applyMigrations, fromPool } from 'nuxt-pglite\u002Fmigrations'\n\nconst pool = new Pool({ connectionString: process.env.DATABASE_URL })\n\ntry {\n  console.log(await applyMigrations(fromPool(pool), 'server\u002Fdatabase\u002Fmigrations'))\n} finally {\n  await pool.end()\n}\n","scripts\u002Fmigrate.ts",[218,798,799,818,841,845,886,890,897,936,945,961],{"__ignoreMap":237},[241,800,801,803,805,808,810,812,814,816],{"class":243,"line":244},[241,802,248],{"class":247},[241,804,252],{"class":251},[241,806,807],{"class":255}," Pool",[241,809,259],{"class":251},[241,811,262],{"class":247},[241,813,265],{"class":251},[241,815,401],{"class":268},[241,817,272],{"class":251},[241,819,820,822,824,826,828,831,833,835,837,839],{"class":243,"line":275},[241,821,248],{"class":247},[241,823,252],{"class":251},[241,825,289],{"class":255},[241,827,349],{"class":251},[241,829,830],{"class":255}," fromPool",[241,832,259],{"class":251},[241,834,262],{"class":247},[241,836,265],{"class":251},[241,838,228],{"class":268},[241,840,272],{"class":251},[241,842,843],{"class":243,"line":282},[241,844,279],{"emptyLinePlaceholder":278},[241,846,847,849,852,854,857,859,861,864,867,869,872,874,877,879,882,884],{"class":243,"line":302},[241,848,318],{"class":317},[241,850,851],{"class":255}," pool ",[241,853,324],{"class":251},[241,855,856],{"class":251}," new",[241,858,807],{"class":327},[241,860,330],{"class":255},[241,862,863],{"class":251},"{",[241,865,866],{"class":553}," connectionString",[241,868,394],{"class":251},[241,870,871],{"class":255}," process",[241,873,355],{"class":251},[241,875,876],{"class":255},"env",[241,878,355],{"class":251},[241,880,881],{"class":255},"DATABASE_URL ",[241,883,426],{"class":251},[241,885,429],{"class":255},[241,887,888],{"class":243,"line":307},[241,889,279],{"emptyLinePlaceholder":278},[241,891,892,895],{"class":243,"line":314},[241,893,894],{"class":247},"try",[241,896,607],{"class":251},[241,898,899,902,904,907,909,912,914,916,918,920,923,925,927,929,931,933],{"class":243,"line":366},[241,900,901],{"class":255},"  console",[241,903,355],{"class":251},[241,905,906],{"class":327},"log",[241,908,330],{"class":553},[241,910,911],{"class":247},"await",[241,913,289],{"class":327},[241,915,330],{"class":553},[241,917,785],{"class":327},[241,919,330],{"class":553},[241,921,922],{"class":255},"pool",[241,924,404],{"class":553},[241,926,349],{"class":251},[241,928,265],{"class":251},[241,930,670],{"class":268},[241,932,341],{"class":251},[241,934,935],{"class":553},"))\n",[241,937,938,940,943],{"class":243,"line":371},[241,939,426],{"class":251},[241,941,942],{"class":247}," finally",[241,944,607],{"class":251},[241,946,947,950,953,955,958],{"class":243,"line":388},[241,948,949],{"class":247},"  await",[241,951,952],{"class":255}," pool",[241,954,355],{"class":251},[241,956,957],{"class":327},"end",[241,959,960],{"class":553},"()\n",[241,962,963],{"class":243,"line":423},[241,964,965],{"class":251},"}\n",[214,967,968],{},"Concurrent appliers on the same database (two dev processes, a CI job and a deploy) take turns behind an advisory lock. The entry depends on Node built-ins only.",[478,970,972],{"id":971},"the-tracking-table","The tracking table",[214,974,975,976,979,980,983],{},"Applied migrations are recorded in ",[218,977,978],{},"netlify.migrations"," by default. That is Netlify's bookkeeping, so that a Netlify deploy and the local database agree on what was applied; any other platform just sees a tracking table. ",[218,981,982],{},"table"," renames it:",[231,985,987],{"className":233,"code":986,"filename":235,"language":236,"meta":237,"style":237},"export default definePGliteServerConfig({\n  init: (pg) => applyMigrations(pg, migrations, { table: 'public.schema_migrations' }),\n})\n",[218,988,989,1001,1046],{"__ignoreMap":237},[241,990,991,993,995,997,999],{"class":243,"line":244},[241,992,374],{"class":247},[241,994,377],{"class":247},[241,996,380],{"class":327},[241,998,330],{"class":255},[241,1000,385],{"class":251},[241,1002,1003,1005,1007,1009,1011,1013,1015,1017,1019,1021,1024,1026,1028,1031,1033,1035,1038,1040,1042,1044],{"class":243,"line":275},[241,1004,391],{"class":327},[241,1006,394],{"class":251},[241,1008,397],{"class":251},[241,1010,401],{"class":400},[241,1012,404],{"class":251},[241,1014,407],{"class":317},[241,1016,289],{"class":327},[241,1018,412],{"class":255},[241,1020,349],{"class":251},[241,1022,1023],{"class":255}," migrations",[241,1025,349],{"class":251},[241,1027,252],{"class":251},[241,1029,1030],{"class":553}," table",[241,1032,394],{"class":251},[241,1034,265],{"class":251},[241,1036,1037],{"class":268},"public.schema_migrations",[241,1039,341],{"class":251},[241,1041,259],{"class":251},[241,1043,404],{"class":255},[241,1045,420],{"class":251},[241,1047,1048,1050],{"class":243,"line":282},[241,1049,426],{"class":251},[241,1051,429],{"class":255},[214,1053,1054,1055,397,1057,1060],{},"A tool with its own bookkeeping, such as ",[218,1056,736],{},[218,1058,1059],{},"drizzle.__drizzle_migrations","), keeps it separately: each database is tracked by the tool that migrates it, from the same files.",[478,1062,36],{"id":1063},"options",[231,1065,1067],{"className":233,"code":1066,"language":236,"meta":237,"style":237},"await applyMigrations(pg, migrations, {\n  table: 'netlify.migrations', \u002F\u002F the tracking table, `schema.table` or `table`\n  digests: true, \u002F\u002F the drift check, see Edited migrations; a string names another table\n  target: '20261008032022', \u002F\u002F stop at this migration, by full name or by the part before an `_`\n  logger: console, \u002F\u002F anything with `info` and `warn`; silent by default\n})\n",[218,1068,1069,1085,1103,1119,1138,1153],{"__ignoreMap":237},[241,1070,1071,1073,1075,1077,1079,1081,1083],{"class":243,"line":244},[241,1072,911],{"class":247},[241,1074,289],{"class":327},[241,1076,412],{"class":255},[241,1078,349],{"class":251},[241,1080,1023],{"class":255},[241,1082,349],{"class":251},[241,1084,607],{"class":251},[241,1086,1087,1090,1092,1094,1096,1098,1100],{"class":243,"line":275},[241,1088,1089],{"class":553},"  table",[241,1091,394],{"class":251},[241,1093,265],{"class":251},[241,1095,978],{"class":268},[241,1097,341],{"class":251},[241,1099,349],{"class":251},[241,1101,1102],{"class":310}," \u002F\u002F the tracking table, `schema.table` or `table`\n",[241,1104,1105,1108,1110,1114,1116],{"class":243,"line":282},[241,1106,1107],{"class":553},"  digests",[241,1109,394],{"class":251},[241,1111,1113],{"class":1112},"sfNiH"," true",[241,1115,349],{"class":251},[241,1117,1118],{"class":310}," \u002F\u002F the drift check, see Edited migrations; a string names another table\n",[241,1120,1121,1124,1126,1128,1131,1133,1135],{"class":243,"line":302},[241,1122,1123],{"class":553},"  target",[241,1125,394],{"class":251},[241,1127,265],{"class":251},[241,1129,1130],{"class":268},"20261008032022",[241,1132,341],{"class":251},[241,1134,349],{"class":251},[241,1136,1137],{"class":310}," \u002F\u002F stop at this migration, by full name or by the part before an `_`\n",[241,1139,1140,1143,1145,1148,1150],{"class":243,"line":307},[241,1141,1142],{"class":553},"  logger",[241,1144,394],{"class":251},[241,1146,1147],{"class":255}," console",[241,1149,349],{"class":251},[241,1151,1152],{"class":310}," \u002F\u002F anything with `info` and `warn`; silent by default\n",[241,1154,1155,1157],{"class":243,"line":314},[241,1156,426],{"class":251},[241,1158,429],{"class":255},[214,1160,1161,1164,1165,1167],{},[218,1162,1163],{},"readMigrations(dir)"," lists the migrations as ",[218,1166,224],{}," sees them, for tooling.",[214,1169,1170,1171,1174,1175,1178,1179,1182,1183,1185,1186,1190],{},"A failing migration throws a ",[218,1172,1173],{},"MigrationError",", with the ",[218,1176,1177],{},"migration"," name and the database error as ",[218,1180,1181],{},"cause",", once its transaction is rolled back; the migrations after it are not run. Thrown from ",[218,1184,220],{},", it leaves the socket ",[436,1187,1189],{"href":1188},"\u002Fguide\u002Fdevtools#when-init-fails","refusing clients"," with that message until the cause is fixed.",[478,1192,1194],{"id":1193},"testing-a-migrated-database","Testing a migrated database",[214,1196,1197,1198,1203,1204,1206,1207,1209,1210,1216,1217,1219],{},"A test database from ",[436,1199,1200],{"href":118},[218,1201,1202],{},"nuxt-pglite\u002Ftesting"," runs the config's ",[218,1205,220],{},", so the migrations are applied to it as they are to the development one, and tests run against the schema the files produce. Build the directory from the config file's location, as above: a test runner's working directory is not always the app's. The config file is loaded outside Nuxt there, where ",[218,1208,473],{}," needs ",[436,1211,1213],{"href":1212},"\u002Frecipes\u002Ftesting#config-files",[218,1214,1215],{},"alias","; importing from ",[218,1218,228],{}," works in both places.",[214,1221,1222,1223,1226],{},"To start each test from the migrated schema, apply them once and ",[436,1224,1225],{"href":125},"fork"," per test, rather than creating a database per test.",[1228,1229,1230],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}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);}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":237,"searchDepth":244,"depth":275,"links":1232},[1233,1234,1237,1238,1239],{"id":480,"depth":275,"text":481},{"id":711,"depth":275,"text":712,"children":1235},[1236],{"id":766,"depth":282,"text":767},{"id":971,"depth":275,"text":972},{"id":1063,"depth":275,"text":36},{"id":1193,"depth":275,"text":1194},"A folder of SQL files, applied from init in development; in production, applied by you or by the platform.","md",null,{},{"title":28,"icon":110},{"title":105,"description":1240},"XQ2JSPBFpPtHMBewZ1r4exnfNvZ2BlzKB8gVfNC5e_U",[1242,1248],{"title":112,"path":113,"stem":114,"description":1249,"icon":115,"children":-1},"Why an applied migration never runs again, how applyMigrations notices an edited file, and the way out.",1791474259253]