{"id":44041,"library":"tiny-postgres-migrator","title":"Tiny Postgres Migrator","description":"Tiny Postgres Migrator is a lightweight, zero-config database schema migration tool specifically designed for the 'postgres' Node.js driver (ESM-native). Version 2.0.0 runs entirely from the command line or programmatically, supports both async/await and simple SQL file migrations. Unlike larger ORM-based tools (e.g., Sequelize, TypeORM), it offers minimal overhead, no external dependencies besides 'postgres', and a straightforward up/down migration pattern with plain SQL files. The library has a monthly release cadence and is actively maintained for bug fixes and Node.js compatibility.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/tomm/tiny-postgres-migrator","tags":["javascript"],"install":[{"cmd":"npm install tiny-postgres-migrator","lang":"bash","label":"npm"},{"cmd":"yarn add tiny-postgres-migrator","lang":"bash","label":"yarn"},{"cmd":"pnpm add tiny-postgres-migrator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer: the underlying PostgreSQL driver for Node.js. Migration uses the 'postgres' client for database connections.","package":"postgres","optional":false}],"imports":[{"note":"The library is ESM-only. CommonJS require() will fail.","wrong":"const migrate = require('tiny-postgres-migrator')","symbol":"migrate","correct":"import { migrate } from 'tiny-postgres-migrator'"},{"note":"Named export 'migrate' is the recommended usage, but default export also exists.","wrong":"const migrate = require('tiny-postgres-migrator').default","symbol":"default export (migrate)","correct":"import migrate from 'tiny-postgres-migrator'"},{"note":"Types are exported for TypeScript usage, best imported as type-only to avoid runtime overhead.","wrong":"import { MigrationConfig } from 'tiny-postgres-migrator' (if using transpilation)","symbol":"type imports","correct":"import type { MigrationConfig } from 'tiny-postgres-migrator'"}],"quickstart":{"code":"import { migrate } from 'tiny-postgres-migrator';\nimport postgres from 'postgres';\n\nconst sql = postgres({\n  host: 'localhost',\n  port: 5432,\n  database: 'mydb',\n  user: 'user',\n  password: process.env.DB_PASSWORD ?? '',\n});\n\nawait migrate({\n  sql,\n  migrationsTable: 'migrations',\n  dir: './migrations',\n  direction: 'up', // or 'down'\n});\n\nawait sql.end();","lang":"typescript","description":"Shows programmatic usage: connect to PostgreSQL, run all 'up' migrations from a directory, and close the connection."},"warnings":[{"fix":"Update imports: either use named import { migrate } or default import with object destructuring.","message":"Version 2.0.0 changed the default export from a function to an object. Migrating from v1 requires destructuring 'migrate' or using default import.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Switch to programmatic usage using the 'migrate' function.","message":"The CLI usage via npx tiny-postgres-migrator may be removed in future versions; prefer programmatic invocation.","severity":"deprecated","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Ensure each migration file exports at least an 'up' function. Example: export async function up(sql) { ... }.","message":"Migration files must export 'up' and 'down' functions or be SQL files. Forgetting to export a named function causes silent failures.","severity":"gotcha","affected_versions":"*"},{"fix":"Always provide a 'migrationsTable' in the config object.","message":"The 'migrationsTable' option is required in v2.0.0. If omitted, migration fails with 'Cannot read properties of undefined'.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Upgrade to Node.js 18 or later.","message":"Node.js 18+ is required. Users on Node.js 16 will see 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM'.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.0':28 'activ':82 'async/await':39 'base':49 'besid':61 'bug':85 'cadenc':79 'command':33 'compat':89 'config':12 'databas':13 'depend':60 'design':18 'driver':23 'e.g':51 'entir':30 'esm':25 'esm-nat':24 'extern':59 'file':43,72 'fix':86 'javascript':90 'larger':46 'librari':74 'lightweight':9 'line':34 'maintain':83 'migrat':3,6,15,44,67 'minim':56 'month':77 'nativ':26 'node.js':22,88 'offer':55 'orm':48 'orm-bas':47 'overhead':57 'pattern':68 'plain':70 'postgr':2,5,21,62 'programmat':36 'releas':78 'run':29 'schema':14 'sequel':52 'simpl':41 'specif':17 'sql':42,71 'straightforward':65 'support':37 'tini':1,4 'tool':16,50 'typeorm':53 'unlik':45 'up/down':66 'version':27 'zero':11 'zero-config':10","created_at":"2026-06-05T17:02:41.955570+00:00","updated_at":"2026-06-05T17:02:41.955570+00:00","problems":[{"fix":"Install the peer dependency: npm install postgres","cause":"The 'postgres' driver is not installed as a dependency.","error":"Cannot find package 'postgres'"},{"fix":"Add \"type\": \"module\" in package.json or rename file to .mjs","cause":"The project is not configured as a module (ESM).","error":"Cannot use import statement outside a module"},{"fix":"Use dynamic import: const { migrate } = await import('tiny-postgres-migrator');","cause":"Incorrect import style. Likely using require() on ESM package.","error":"migrate is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/tomm/tiny-postgres-migrator#readme","github":"https://github.com/tomm/tiny-postgres-migrator","docs":null,"changelog":null,"pypi":null,"npm":"tiny-postgres-migrator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}