{"id":49458,"library":"supabase-migrator","title":"Supabase Migrator","description":"Supabase Migrator (v1.1.4) is a comprehensive migration and cleanup toolkit for Supabase PostgreSQL databases. It provides automated schema migrations, backup/restore, and database cleanup operations specifically tailored for Supabase projects. Features include migration versioning, dry-run support, and built-in safety checks to prevent accidental data loss. Released regularly with fixes and updates. Differentiates from generic migration tools by understanding Supabase's specific object types (auth, storage, realtime) and offering cleanup commands for orphaned records.","status":"active","version":"1.1.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","supabase","migration","postgres","postgresql","database","backup","restore","cleanup","typescript"],"install":[{"cmd":"npm install supabase-migrator","lang":"bash","label":"npm"},{"cmd":"yarn add supabase-migrator","lang":"bash","label":"yarn"},{"cmd":"pnpm add supabase-migrator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for interacting with Supabase APIs beyond raw SQL.","package":"@supabase/supabase-js","optional":false}],"imports":[{"note":"ESM-only; named export. CJS require will fail.","wrong":"const { supabaseMigrator } = require('supabase-migrator')","symbol":"supabaseMigrator","correct":"import { supabaseMigrator } from 'supabase-migrator'"},{"note":"Named export, not default.","wrong":"import runMigrations from 'supabase-migrator'","symbol":"runMigrations","correct":"import { runMigrations } from 'supabase-migrator'"},{"note":"Function is named cleanupDatabase, not cleanDatabase.","wrong":"import { cleanDatabase } from 'supabase-migrator'","symbol":"cleanupDatabase","correct":"import { cleanupDatabase } from 'supabase-migrator'"},{"note":"Named export for backup functionality.","wrong":null,"symbol":"backupDatabase","correct":"import { backupDatabase } from 'supabase-migrator'"}],"quickstart":{"code":"import { supabaseMigrator } from 'supabase-migrator';\nimport { createClient } from '@supabase/supabase-js';\n\nasync function migrate() {\n  const supabase = createClient(process.env.SUPABASE_URL ?? '', process.env.SUPABASE_KEY ?? '');\n  const migrator = supabaseMigrator({ supabase });\n  \n  // Dry-run first\n  await migrator.runMigrations({ dryRun: true });\n  \n  // Apply migrations\n  await migrator.runMigrations();\n  \n  // Backup\n  await migrator.backupDatabase({ output: './backup.sql' });\n  \n  // Cleanup orphaned rows\n  await migrator.cleanupDatabase();\n}\n\nmigrate().catch(console.error);","lang":"typescript","description":"Initializes the migrator with a Supabase client, runs migrations with dry-run, then performs backup and cleanup."},"warnings":[{"fix":"Upgrade @supabase/supabase-js to version 2+.","message":"Requires @supabase/supabase-js v2 or higher. v1 will cause runtime errors.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Always test on a staging database first.","message":"Dry-run mode does not guarantee no side effects; some SQL triggers may still fire.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace `import supabaseMigrator from 'supabase-migrator'` with `import { supabaseMigrator } from 'supabase-migrator'`.","message":"The `supabaseMigrator` default export is deprecated; use named export instead.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use Supabase Admin API to manage realtime subscriptions.","message":"The `cleanupDatabase` function does not affect realtime subscriptions; you must clean them separately.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'accident':48 'auth':69 'autom':19 'backup':85 'backup/restore':22 'built':42 'built-in':41 'check':45 'cleanup':11,25,74,87 'command':75 'comprehens':8 'data':49 'databas':16,24,84 'differenti':57 'dri':37 'dry-run':36 'featur':32 'fix':54 'generic':59 'includ':33 'javascript':79 'loss':50 'migrat':2,4,9,21,34,60,81 'object':67 'offer':73 'oper':26 'orphan':77 'postgr':82 'postgresql':15,83 'prevent':47 'project':31 'provid':18 'realtim':71 'record':78 'regular':52 'releas':51 'restor':86 'run':38 'safeti':44 'schema':20 'specif':27,66 'storag':70 'supabas':1,3,14,30,64,80 'support':39 'tailor':28 'tool':61 'toolkit':12 'type':68 'typescript':88 'understand':63 'updat':56 'v1.1.4':5 'version':35","created_at":"2026-06-07T17:01:52.809410+00:00","updated_at":"2026-06-07T17:01:52.809410+00:00","problems":[{"fix":"import { supabaseMigrator } from 'supabase-migrator';","cause":"Using default import instead of named import.","error":"Error: supabaseMigrator is not a function"},{"fix":"Add \"type\": \"module\" to package.json and use import syntax.","cause":"ESM-only module; installed as CommonJS or missing 'type': 'module' in package.json.","error":"Cannot find module 'supabase-migrator' (or its corresponding type declarations)"},{"fix":"Ensure createClient is called with valid SUPABASE_URL and SUPABASE_KEY.","cause":"Missing or misconfigured Supabase client.","error":"TypeError: supabase is not defined"},{"fix":"Use migrator.rollback() to revert the migration or set force: true.","cause":"Migration has already been run. Use --force or rollback first.","error":"Error: Migration already applied: 2023-01-01_init"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"supabase-migrator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}