{"id":23790020,"url":"https://github.com/blackglory/migration-files","last_synced_at":"2025-09-08T16:32:04.420Z","repository":{"id":44955783,"uuid":"305228975","full_name":"BlackGlory/migration-files","owner":"BlackGlory","description":"🌲 A utility for reading SQL-based migration files.","archived":false,"fork":false,"pushed_at":"2024-03-23T16:47:32.000Z","size":883,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-17T04:27:09.422Z","etag":null,"topics":["library","nodejs","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/migration-files","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/BlackGlory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-10-19T01:08:25.000Z","updated_at":"2025-03-18T15:16:23.000Z","dependencies_parsed_at":"2024-03-23T17:41:07.620Z","dependency_job_id":"7f669c5a-6ff3-4227-81f4-f21e0f606c0b","html_url":"https://github.com/BlackGlory/migration-files","commit_stats":{"total_commits":64,"total_committers":2,"mean_commits":32.0,"dds":0.140625,"last_synced_commit":"a46e1480f2b85b58579a35b95dd01d46bdd0ca33"},"previous_names":["blackglory/migrations-file"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/BlackGlory/migration-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fmigration-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fmigration-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fmigration-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fmigration-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/migration-files/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fmigration-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274213591,"owners_count":25242506,"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-09-08T02:00:09.813Z","response_time":121,"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":["library","nodejs","npm-package","typescript"],"created_at":"2025-01-01T17:18:07.557Z","updated_at":"2025-09-08T16:32:04.036Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# migration-files\nUtilities for SQL-based migration files.\n\n## Install\n```sh\nnpm install --save migration-files\n# or\nyarn add migration-files\n```\n\n## Usage\n```ts\nimport { map } from 'extra-promise'\nimport { findMigrationFilenames, readMigrationFile } from 'migration-files'\n\nconst filenames = await findMigrationFilenames('./migrations')\nconst migrations = await map(filenames, readMigrationFile)\n```\n\n## Migration format\n001-initial.sql\n```sql\n--------------------------------------------------------------------------------\n-- Up\n--------------------------------------------------------------------------------\nCREATE TABLE test (\n  id INTEGER PRIMARY KEY\n);\n\n--------------------------------------------------------------------------------\n-- Down\n--------------------------------------------------------------------------------\nDROP TABLE test;\n```\n\n002-add name column.sql\n```sql\n--------------------------------------------------------------------------------\n-- Up\n--------------------------------------------------------------------------------\nALTER TABLE test\n  ADD COLUMN name TEXT;\n\n--------------------------------------------------------------------------------\n-- Down\n--------------------------------------------------------------------------------\n-- https://www.sqlite.org/faq.html#q11\nBEGIN TRANSACTION;\n  CREATE TEMPORARY TABLE test_backup (\n    id   INTEGER PRIMARY KEY\n  , name TEXT\n  );\n  INSERT INTO test_backup\n        SELECT id, name FROM test;\n  DROP TABLE test;\n  CREATE TABLE test (\n    id\n  );\n  INSERT INTO test\n        SELECT id FROM test_backup;\n  DROP TABLE test_backup;\nCOMMIT;\n```\n\n## API\n```ts\ninterface IMigration {\n  filename: string\n  version: number\n  name: string\n  up: string\n  down: string\n}\n```\n\n### readMigrationFile\n```ts\nfunction readMigrationFile(filename: string): Promise\u003cIMigration\u003e\n```\n\n### findMigrationFilenames\n```ts\nfunction findMigrationFilenames(dirname: string): Promise\u003cstring[]\u003e\n```\n\n### parseMigrationFile\n```ts\nfunction parseMigrationFile(filename: string, content: string): IMigration\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fmigration-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fmigration-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fmigration-files/lists"}