{"id":21483625,"url":"https://github.com/andrenarchy/lauf","last_synced_at":"2026-02-26T10:16:51.676Z","repository":{"id":57710698,"uuid":"512274279","full_name":"andrenarchy/lauf","owner":"andrenarchy","description":"🏃‍♀️ Migration runner for Typescript","archived":false,"fork":false,"pushed_at":"2025-07-14T22:45:09.000Z","size":1087,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-16T03:41:58.289Z","etag":null,"topics":["migration","postgresql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrenarchy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-09T19:57:22.000Z","updated_at":"2025-07-01T02:47:27.000Z","dependencies_parsed_at":"2023-09-26T01:12:25.249Z","dependency_job_id":"545b4233-0d12-4a7f-853a-94f64170328d","html_url":"https://github.com/andrenarchy/lauf","commit_stats":{"total_commits":38,"total_committers":3,"mean_commits":"12.666666666666666","dds":0.5526315789473684,"last_synced_commit":"c5c5fe0bc9765d78ea0308a68b8456c19967bed4"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/andrenarchy/lauf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenarchy%2Flauf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenarchy%2Flauf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenarchy%2Flauf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenarchy%2Flauf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrenarchy","download_url":"https://codeload.github.com/andrenarchy/lauf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenarchy%2Flauf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266977744,"owners_count":24015478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["migration","postgresql","typescript"],"created_at":"2024-11-23T12:48:31.941Z","updated_at":"2026-02-26T10:16:46.651Z","avatar_url":"https://github.com/andrenarchy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏃‍♀️ lauf\n[![CI](https://github.com/andrenarchy/lauf/actions/workflows/ci.yaml/badge.svg)](https://github.com/andrenarchy/lauf/actions/workflows/ci.yaml) [![npm](https://img.shields.io/npm/v/lauf)](https://www.npmjs.com/package/lauf)\n\n*lauf* is a lightweight migration runner for Typescript.\n\n🐘 Uses PostgreSQL for keeping track of migrations.\u003cbr/\u003e\n🔗 Guaranteed consistency for your PostgreSQL data via transactions.\u003cbr/\u003e\n☁️ Handle arbitrary further databases or file storages in your migrations (e.g., S3 or GCS).\u003cbr/\u003e\n👩‍💻 Migration order is defined in code, not implicitly through files in a directory.\u003cbr/\u003e\n📦 Use any packages you want in your migrations.\u003cbr/\u003e\n🪶 Lightweight: only a single dependency (`pg`).\n\n## Documentation\n\n### Example\n\nMigrations can be run like\n```typescript\nimport { runMigrations } from 'lauf'\nimport pg from 'pg'\n\nawait runMigrations({\n  setup: async () =\u003e {\n    const pgClient = new pg.Client({ connectionString: process.env.POSTGRESQL_URL })\n    await pgClient.connect()\n    return { pgClient }\n  },\n  teardown: ({ pgClient }) =\u003e pgClient.end(),\n  migrations: [\n    {\n      id: '2022-07-09-create-users',\n      description: 'Create users',\n      up: ({ pgClient }) =\u003e pgClient.query(\n        `CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`\n      ),\n      down: ({ pgClient }) =\u003e pgClient.query(`DROP TABLE users;`),\n    },\n    // add further migrations\n  ],\n  logger: (msg) =\u003e console.log(msg)\n})\n```\n\n### Splitting in multiple files\n\nFor organizing migrations, each migration can also be kept in a separate file like\n\n```typescript\nimport { Migration } from 'lauf'\n\nconst migration: Migration = {\n  id: '2022-07-09-create-users',\n  description: 'Create users',\n  up: ({ pgClient }) =\u003e pgClient.query(\n    `CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`\n  ),\n  down: ({ pgClient }) =\u003e pgClient.query(`DROP TABLE users;`),\n}\n\nexport default migration\n```\n\nThen the files can be run as follows:\n```typescript\nawait runMigrations({\n  // see above\n  migrations: [\n    import('./2022-07-10-create-users-table.js'),\n    // add further migrations here\n  ].map(v =\u003e v.default),\n})\n```\n\n### Migrate down/up\n\nSetting the `mode` option to `up` or `down` you can migrate step-wise up or down. The default value is `latest` which runs all migrations.\n\n### Further databases or storages\n\nThe `setup` function can return arbitrary further properties. All returned properties will be passed to the migrations and the `teardown` function. For example:\n\n```typescript\nawait runMigrations({\n  setup: async () =\u003e {\n    const pgClient = new pg.Client({ connectionString: process.env.POSTGRESQL_URL })\n    await pgClient.connect()\n    const gcs = new Storage(process.env.GCS_CREDENTIALS)\n    return { pgClient, gcs }\n  },\n  teardown: ({ pgClient, gcs }) =\u003e pgClient.end(),\n  migrations: [\n    {\n      id: '2022-07-09-create-users',\n      description: 'Create users',\n      up: async ({ pgClient, gcs }) =\u003e {\n        await pgClient.query(\n        `CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`\n        )\n        await gcs.upload(...)\n      },\n      down: ({ pgClient, gcs }) =\u003e pgClient.query(`DROP TABLE users;`),\n    },\n    // add further migrations\n  ],\n})\n```\n\n## Tests\n\n```bash\ndocker run -d --name pg-lauf -e POSTGRES_PASSWORD=test -p 5432:5432 postgres:14\nexport POSTGRESQL_URL=postgres://postgres:test@127.0.0.1:5432/postgres?sslmode=disable\nnpm run build \u0026\u0026 npm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrenarchy%2Flauf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrenarchy%2Flauf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrenarchy%2Flauf/lists"}