{"_id":"@akoenig/effect-sql-inline-migrations","_rev":"4-4c7078780a60035303854e8f9e09347b","name":"@akoenig/effect-sql-inline-migrations","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@akoenig/effect-sql-inline-migrations","version":"1.0.0","author":{"name":"André König","email":"hi@andrekoenig.com"},"license":"MIT","_id":"@akoenig/effect-sql-inline-migrations@1.0.0","maintainers":[{"name":"akoenig","email":"hello@andrekoenig.de"}],"dist":{"shasum":"1bd5c075a1df7748aefee769d7e917f78efaafc1","tarball":"https://registry.npmjs.org/@akoenig/effect-sql-inline-migrations/-/effect-sql-inline-migrations-1.0.0.tgz","fileCount":8,"integrity":"sha512-IEXuBqFdPx3poVsdOwF8b6zteV4qIVJIkrBWBQi1Z8NS8f86rWqNiZYEtJW/cfHRaoLpUP86XP/VTrFjFvdCnw==","signatures":[{"sig":"MEUCIG6yODW3tUgJ1QLVrM8aFGgfhaUrUO3LnvA5w4FgtWgvAiEA9iDSuu4fNG9x7PJZI2PSOxC6gV5npjEgdIjZympNUKI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8372},"_from":"file:akoenig-effect-sql-inline-migrations-1.0.0.tgz","exports":{".":{"types":"./dist/mod.d.ts","default":"./dist/mod.js"}},"scripts":{"build":"tsc","scratchpad":"tsx scratchpad/mod.ts"},"_npmUser":{"name":"akoenig","email":"hello@andrekoenig.de"},"_resolved":"/private/var/folders/5m/5qwfkcpn6sg85m5g3hqc_by40000gn/T/d0014d11468fb66959b8d724ad94767f/akoenig-effect-sql-inline-migrations-1.0.0.tgz","_integrity":"sha512-IEXuBqFdPx3poVsdOwF8b6zteV4qIVJIkrBWBQi1Z8NS8f86rWqNiZYEtJW/cfHRaoLpUP86XP/VTrFjFvdCnw==","_npmVersion":"10.9.2","description":"A migration loader that doesn't consult the filesystem when fetching database migrations.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.4","typescript":"^5.8.3","@biomejs/biome":"1.9.4","@effect/sql-libsql":"^0.27.9","@effect/platform-node":"^0.85.8","@effect/language-service":"^0.19.0"},"peerDependencies":{"effect":"^3","@effect/sql":"^0.37.9"},"_npmOperationalInternal":{"tmp":"tmp/effect-sql-inline-migrations_1.0.0_1749325424564_0.9120613819186658","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@akoenig/effect-sql-inline-migrations","version":"1.0.1","author":{"name":"André König","email":"hi@andrekoenig.com"},"license":"MIT","_id":"@akoenig/effect-sql-inline-migrations@1.0.1","maintainers":[{"name":"akoenig","email":"hello@andrekoenig.de"}],"dist":{"shasum":"002e3260b6b4cf70f30afc9bd9cebd12a436199d","tarball":"https://registry.npmjs.org/@akoenig/effect-sql-inline-migrations/-/effect-sql-inline-migrations-1.0.1.tgz","fileCount":4,"integrity":"sha512-7ctxd757uB9d+CuQDG9nciragTW3P6B8vOPPbITNcEQygD26qnCkC3unX9cyHG/yJrbH0k7D3Oz5Y6FqeqZ48g==","signatures":[{"sig":"MEYCIQCNcHXqxDPPEIEqtaQ+ShGvbERfZSG10GT4AxAsYte62wIhANkgvaZcKjASbKHBu2fZhnSetG/urLUYfqgHqKijv6nW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5868},"_from":"file:akoenig-effect-sql-inline-migrations-1.0.1.tgz","exports":{".":{"types":"./dist/mod.d.ts","default":"./dist/mod.js"}},"scripts":{"build":"tsc","scratchpad":"tsx scratchpad/mod.ts"},"_npmUser":{"name":"akoenig","email":"hello@andrekoenig.de"},"_resolved":"/private/var/folders/5m/5qwfkcpn6sg85m5g3hqc_by40000gn/T/e87b86c6ffb211c8889a3888d1999740/akoenig-effect-sql-inline-migrations-1.0.1.tgz","_integrity":"sha512-7ctxd757uB9d+CuQDG9nciragTW3P6B8vOPPbITNcEQygD26qnCkC3unX9cyHG/yJrbH0k7D3Oz5Y6FqeqZ48g==","_npmVersion":"10.9.2","description":"A migration loader that doesn't consult the filesystem when fetching database migrations.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.4","typescript":"^5.8.3","@biomejs/biome":"1.9.4","@effect/sql-libsql":"^0.27.9","@effect/platform-node":"^0.85.8","@effect/language-service":"^0.19.0","@akoenig/effect-sql-inline-migrations":"^1.0.0"},"peerDependencies":{"effect":"^3","@effect/sql":"^0.37.9"},"_npmOperationalInternal":{"tmp":"tmp/effect-sql-inline-migrations_1.0.1_1749325644094_0.777888128912914","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@akoenig/effect-sql-inline-migrations","version":"1.0.2","author":{"name":"André König","email":"hi@andrekoenig.com"},"license":"MIT","_id":"@akoenig/effect-sql-inline-migrations@1.0.2","maintainers":[{"name":"akoenig","email":"hello@andrekoenig.de"}],"dist":{"shasum":"25a3792d1ca3a74b5006c4cc2cc58aeae84c09cc","tarball":"https://registry.npmjs.org/@akoenig/effect-sql-inline-migrations/-/effect-sql-inline-migrations-1.0.2.tgz","fileCount":8,"integrity":"sha512-R9eX2ifyFYDLmM0LcZ2KXFEOAS5ICgzgDL6tGMkQDOxNaDe5Yv8RzmJ5uYE7I5ggRlFli2K7X1jaqUlzSNqVmg==","signatures":[{"sig":"MEYCIQC2s3imK644BJx424doznTXu/hDh3Q20XZXsTn5AfXLnwIhAOzGgcIOpcxH6f6M2U3Sys5TOQNEnX5mU47CBetxf2Bq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8502},"_from":"file:akoenig-effect-sql-inline-migrations-1.0.2.tgz","exports":{".":{"types":"./dist/mod.d.ts","default":"./dist/mod.js"}},"scripts":{"build":"tsc","scratchpad":"tsx scratchpad/mod.ts"},"_npmUser":{"name":"akoenig","email":"hello@andrekoenig.de"},"_resolved":"/private/var/folders/5m/5qwfkcpn6sg85m5g3hqc_by40000gn/T/nix-shell.a04Tls/a201c47bc62a782bb96c33f5eaf0e994/akoenig-effect-sql-inline-migrations-1.0.2.tgz","_integrity":"sha512-R9eX2ifyFYDLmM0LcZ2KXFEOAS5ICgzgDL6tGMkQDOxNaDe5Yv8RzmJ5uYE7I5ggRlFli2K7X1jaqUlzSNqVmg==","_npmVersion":"10.9.2","description":"A migration loader that doesn't consult the filesystem when fetching database migrations.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.4","typescript":"^5.8.3","@biomejs/biome":"1.9.4","@effect/sql-libsql":"^0.27.9","@effect/platform-node":"^0.85.8","@effect/language-service":"^0.19.0","@akoenig/effect-sql-inline-migrations":"^1.0.0"},"peerDependencies":{"effect":"^3","@effect/sql":"^0.37.9"},"_npmOperationalInternal":{"tmp":"tmp/effect-sql-inline-migrations_1.0.2_1749491525801_0.06026962122558244","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@akoenig/effect-sql-inline-migrations","version":"1.1.0","author":{"name":"André König","email":"hi@andrekoenig.com"},"license":"MIT","exports":{".":{"types":"./dist/mod.d.ts","default":"./dist/mod.js"}},"peerDependencies":{"@effect/sql":"^0.37.9","effect":"^3"},"devDependencies":{"@akoenig/effect-sql-inline-migrations":"^1.0.0","@biomejs/biome":"1.9.4","@effect/language-service":"^0.19.0","@effect/platform-node":"^0.85.8","@effect/sql-libsql":"^0.27.9","tsx":"^4.19.4","typescript":"^5.8.3"},"scripts":{"build":"tsc","scratchpad":"tsx scratchpad/mod.ts"},"_id":"@akoenig/effect-sql-inline-migrations@1.1.0","description":"A migration loader that doesn't consult the filesystem when fetching database migrations.","_integrity":"sha512-eFSQzLVAV1ZEVUGdQ1BvEOa1DgXphhfWPmW8K9xEXb9ZnLh9jgvNOUjBsFMnNcVVI9r89LnPM45BbGmaw0MTKw==","_resolved":"/private/var/folders/5m/5qwfkcpn6sg85m5g3hqc_by40000gn/T/nix-shell.QowP7c/bef2e7c2ce41ca3f307f3125b229691c/akoenig-effect-sql-inline-migrations-1.1.0.tgz","_from":"file:akoenig-effect-sql-inline-migrations-1.1.0.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-eFSQzLVAV1ZEVUGdQ1BvEOa1DgXphhfWPmW8K9xEXb9ZnLh9jgvNOUjBsFMnNcVVI9r89LnPM45BbGmaw0MTKw==","shasum":"1bfa5048315106c28cfc567c00c091c177d20d68","tarball":"https://registry.npmjs.org/@akoenig/effect-sql-inline-migrations/-/effect-sql-inline-migrations-1.1.0.tgz","fileCount":8,"unpackedSize":8510,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCr7WrdDvAPP80A7+h/ftUEsCm+FOzxQWDx4Bt9IxyvggIhAOmaIh3+qbOer9rxmHkR2xkOGxK7e533KTn0W8V78Iqm"}]},"_npmUser":{"name":"akoenig","email":"hello@andrekoenig.de"},"directories":{},"maintainers":[{"name":"akoenig","email":"hello@andrekoenig.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/effect-sql-inline-migrations_1.1.0_1749491900455_0.6355529332008447"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-07T19:43:44.431Z","modified":"2025-06-09T17:58:20.802Z","1.0.0":"2025-06-07T19:43:44.747Z","1.0.1":"2025-06-07T19:47:24.273Z","1.0.2":"2025-06-09T17:52:05.991Z","1.1.0":"2025-06-09T17:58:20.642Z"},"author":{"name":"André König","email":"hi@andrekoenig.com"},"license":"MIT","description":"A migration loader that doesn't consult the filesystem when fetching database migrations.","maintainers":[{"name":"akoenig","email":"hello@andrekoenig.de"}],"readme":"## Effect SQL Inline Migrations\n\nA migration loader that doesn't consult the filesystem when fetching database migrations.\n\n## When is this useful?\n\nThis is useful whenever you have a use case where filesystem access is too slow when running migrations.\n\nFor example, consider a use case where each tenant has its own database. When rolling out a new release, you need to ensure that migrations are applied for every tenant. Doing this from the outside can be too cumbersome and error-prone, so you might decide to perform the migration on each request that hits the respective tenant. Sounds crazy, right? Well, when utilizing the filesystem, it would be crazy, yes. The built-in filesystem loader can add around 50 ms to every request, which would be unacceptable in most scenarios.\n\nBy inlining the migrations (and therefore not accessing the filesystem), it is possible to execute the migrations in 2 ms. Adding 2 ms to every request sounds acceptable. (Disclaimer: I was using SQLite for the benchmark).\n\n## Installation\n\n```sh\npnpm add @akoenig/effect-sql-inline-migrations\n```\n\n## Usage\n\nThis loader is a drop-in replacement. Simply swap the `⁠fromFileSystem` loader that comes with the respective `⁠@effect/sql` database adapter for the `⁠fromArray` loader included in this package.\n\n```ts\nimport { Config, Effect, Layer, pipe } from \"effect\";\nimport { LibsqlClient, LibsqlMigrator } from \"@effect/sql-libsql\";\nimport { NodeContext, NodeRuntime } from \"@effect/platform-node\";\nimport { SqlClient } from \"@effect/sql\";\n\nimport { fromArray } from \"@akoenig/effect-sql-inline-migrations\";\n\nconst SqlLive = LibsqlClient.layerConfig({\n  url: Config.succeed(\"file:scratchpad.db\"),\n});\n\nconst MigratorLive = LibsqlMigrator.layer({\n  loader: fromArray([\n    {\n      name: \"001_create_users_table\",\n      effect: Effect.flatMap(\n        SqlClient.SqlClient,\n        (sql) => sql`\n            CREATE TABLE users (\n              id serial PRIMARY KEY,\n              name varchar(255) NOT NULL,\n              created_at TEXT NOT NULL,\n              updated_at TEXT NOT NULL\n            )\n          `,\n      ),\n    },\n    {\n      name: \"002_create_tasks_table\",\n      effect: Effect.flatMap(\n        SqlClient.SqlClient,\n        (sql) => sql`\n            CREATE TABLE tasks (\n              id serial PRIMARY KEY,\n              description varchar(255) NOT NULL,\n              created_at TEXT NOT NULL\n            )\n          `,\n      ),\n    },\n    {\n      name: \"003_drop_tasks_table\",\n      effect: Effect.flatMap(\n        SqlClient.SqlClient,\n        (sql) => sql`\n            DROP TABLE tasks;\n        `,\n      ),\n    },\n  ]),\n}).pipe(Layer.provide(SqlLive));\n\nconst EnvLive = Layer.mergeAll(SqlLive, MigratorLive).pipe(\n  Layer.provide(NodeContext.layer),\n);\n\nconst program = Effect.gen(function* () {\n  yield* Effect.log(\"Your program is running\");\n});\n\npipe(program, Effect.provide(EnvLive), NodeRuntime.runMain);\n```\n\nAs your migrations grow, you can separate them into their own files and import them to create the ⁠migrations array.\n\n## License\n\nMIT License","readmeFilename":"readme.md"}