{"id":20109773,"url":"https://github.com/hyper63/umzug-hyper-storage","last_synced_at":"2025-03-02T18:24:45.884Z","repository":{"id":65522865,"uuid":"486218263","full_name":"hyper63/umzug-hyper-storage","owner":"hyper63","description":"A Storage Adapter for Umzug that uses Hyper Data to track migrations","archived":false,"fork":false,"pushed_at":"2023-02-24T15:37:48.000Z","size":1351,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T09:18:42.374Z","etag":null,"topics":["database","hyper","hyper-cloud","migrations","scripts","umzug"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyper63.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":"2022-04-27T14:07:16.000Z","updated_at":"2022-11-15T18:05:30.000Z","dependencies_parsed_at":"2025-01-13T05:40:36.796Z","dependency_job_id":"d6cf8013-8c28-4ccb-aa01-b12df64eb3d1","html_url":"https://github.com/hyper63/umzug-hyper-storage","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.18181818181818177","last_synced_commit":"4bb4ef17232e974d76e80813a42e585309d384a7"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper63%2Fumzug-hyper-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper63%2Fumzug-hyper-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper63%2Fumzug-hyper-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper63%2Fumzug-hyper-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyper63","download_url":"https://codeload.github.com/hyper63/umzug-hyper-storage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241550042,"owners_count":19980641,"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","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":["database","hyper","hyper-cloud","migrations","scripts","umzug"],"created_at":"2024-11-13T18:09:23.961Z","updated_at":"2025-03-02T18:24:45.858Z","avatar_url":"https://github.com/hyper63.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e⚡️ umzug-hyper-storage ⚡️\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  umzug-hyper-storage is a zero-dependency \u003ca href=\"https://github.com/sequelize/umzug#storages\"\u003eStorage Adapter\u003c/a\u003e for \u003ca href=\"https://github.com/sequelize/umzug\"\u003eUmzug\u003c/a\u003e\n  that uses a \u003ca href=\"https://hyper.io/product#data\"\u003eHyper Data Service\u003c/a\u003e to track migrations\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://standardjs.com\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code_style-standard-brightgreen.svg\" alt=\"JavaScript Style Guide\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.typescriptlang.org/\"\u003e\n    \u003cimg src=\"https://badges.frapsoft.com/typescript/code/typescript.svg?v=101\" alt=\"TypeScript\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/hyper63/umzug-hyper-storage/actions/workflows/test.yml\"\u003e\n    \u003cimg src=\"https://github.com/hyper63/umzug-hyper-storage/actions/workflows/test.yml/badge.svg\" alt=\"Test\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/hyper63/umzug-hyper-storage/actions/workflows/test.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/coverage-100%25-green\" alt=\"Coverage\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Table of Contents\n\n- [Install](#install)\n- [Getting Started](#getting-started)\n- [Documentation](#documentation)\n- [License](#license)\n\n---\n\n## Install\n\n```sh\nnpm install umzug-hyper-storage\n```\n\n## Getting Started\n\numzug-hyper-storage is a zero-dependency Storage Adapter for\n\u003ca href=\"https://github.com/sequelize/umzug\"\u003eUmzug\u003c/a\u003e that uses a\n\u003ca href=\"https://hyper.io/product#data\"\u003eHyper Data Service\u003c/a\u003e to track\nmigrations.\n\nIt works great as a tool to track and run migrations of your data stored in a\nHyper Data Service. It's also a great generalized script runner, not just for\nrunning migrations.\n\nTo instantiate, provide an instance of\n[`hyper-connect`](https://github.com/hyper63/hyper/tree/main/packages/connect)\nthat connects to your data service you would like to use to track your scripts.\n\n```ts\nimport { Umzug } from 'umzug'\nimport { HyperStorage } from 'umzug-storage-adapter'\nimport { connect } from 'hyper-connect'\n\nconst hyper = connect(process.env.HYPER)\n\nconst umzug = new Umzug({\n  storage: new HyperStorage({ hyper }),\n  // optionally pass a hyper-connect instance to each of your scripts\n  context: {\n    hyper\n  }\n  ...\n})\n\nawait umzug.up() // run migrations\n```\n\nThis will create a document in your Hyper Data Service in the follow shape:\n\n```js\n{\n  _id: 'hyper-scripts-meta',\n  type: '__scripts',\n  migrations: [\n    // array of scripts that have been ran\n  ],\n  createdAt: '2022-04-27T20:30:40.688Z',\n  updatedAt: '2022-04-27T20:30:40.688Z'\n}\n```\n\nAs scripts are ran, their names are appended to the `migrations` array in this\ndocument. If scripts are rolled back, their names are removed from the\n`migrations` array, following normal `Umzug` rules.\n\nThis is how `Umzug` will track which scripts to run, rollback, or have been\npreviously executed.\n\n## Documentation\n\nSee [Umzug Docs](https://github.com/sequelize/umzug) for Umzug usage.\n\nA [`hyper-connect`](https://github.com/hyper63/hyper/tree/main/packages/connect)\ninstance connecting to your Hyper Data Service is required upon instantiation.\n\nYou may also pass a `doc` argument which dictates the shape of the document\nadded to hyper data service:\n\n```ts\ninterface HyperStorageDocArgs {\n  // the _id of the meta document. Defaults to 'hyper-scripts-meta'\n  id?: string;\n  // the type of the meta document. Defaults to '__scripts'\n  type?: string;\n  /**\n   * the field on the meta document to use to store the document type\n   * ie. 'docType'. Defaults to 'type'\n   */\n  typeField?: string;\n  /**\n   * the field on the meta document to store the time\n   * the meta document was created. Defaults to 'createdAt'\n   */\n  createdField?: string;\n  /**\n   * the field on the meta document to store the time\n   * the meta document was last updated. Defaults to 'updatedAt'\n   *\n   * This field is updated each time migrations are ran or rolled back\n   */\n  updatedField?: string;\n}\n```\n\n### Example using `doc`\n\n```ts\nimport { Umzug } from 'umzug'\nimport { HyperStorage } from 'umzug-storage-adapter'\nimport { connect } from 'hyper-connect'\n\nconst hyper = connect(process.env.HYPER)\n\nconst umzug = new Umzug({\n  storage: new HyperStorage({\n    hyper,\n    doc: {\n      type: 'umzug-scripts',\n      createdField: 'created_at',\n      updatedField: 'updated_at'\n    }\n  }),\n  ...\n})\n```\n\n### Passing `hyper-connect` to your `Umzug` scripts\n\nChances are you are running scripts against a Hyper Data Service or\n[Hyper Cloud Application Services](https://docs.hyper.io/applications). You can\nuse [Umzug context](https://github.com/sequelize/umzug#minimal-example) to pass\nan instance of `hyper-connect` to each script ran.\n\nBy using `context` to _inject_ `hyper-connect`, this will make your scripts\neasier to unit test.\n\n```ts\nimport { Umzug } from 'umzug'\nimport { HyperStorage } from 'umzug-storage-adapter'\nimport { connect } from 'hyper-connect'\n\nconst hyper = connect(process.env.HYPER)\n\nconst umzug = new Umzug({\n  storage: new HyperStorage({ hyper }),\n  context: { hyper }\n  ...\n})\n\n// then in your script:\nconst migration = {\n  name: '01-awesome-migration',\n  async up ({ context: { hyper }}) {\n    ... // use hyper-connect to perform migration\n  },\n  async down ({ context: { hyper }}) {\n    ... // use hyper-connect to perform rollback\n  }\n}\n```\n\n---\n\n## License\n\nApache 2.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper63%2Fumzug-hyper-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyper63%2Fumzug-hyper-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper63%2Fumzug-hyper-storage/lists"}