{"id":43270555,"url":"https://github.com/treeder/migrations","last_synced_at":"2026-02-01T15:41:29.096Z","repository":{"id":219862931,"uuid":"750038148","full_name":"treeder/migrations","owner":"treeder","description":"Simple JS database/SQL migration library. ","archived":false,"fork":false,"pushed_at":"2025-09-13T21:21:13.000Z","size":62,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-13T23:31:05.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/treeder.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-29T21:42:08.000Z","updated_at":"2025-09-13T21:21:17.000Z","dependencies_parsed_at":"2024-02-09T03:24:58.661Z","dependency_job_id":"3296707b-90b4-4c28-b880-45bb0a26a66a","html_url":"https://github.com/treeder/migrations","commit_stats":null,"previous_names":["treeder/migrations"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/treeder/migrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fmigrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fmigrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fmigrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fmigrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treeder","download_url":"https://codeload.github.com/treeder/migrations/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fmigrations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28981455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T15:35:50.179Z","status":"ssl_error","status_checked_at":"2026-02-01T15:35:38.075Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-02-01T15:41:28.519Z","updated_at":"2026-02-01T15:41:29.091Z","avatar_url":"https://github.com/treeder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# migrations\n\nSimple SQLite migration library.\n\nThis works with Cloudflare D1 out of the box.\n\nThis will perform the migration and since it's in git, it will also keep a record of all db changes.\n\n## Usage\n\n```sh\nnpm install treeder/migrations\n```\n\n## Using classes\n\nDefine a class with properties. Properties are just like Lit component properties so they have a similar feel.\n\n```js\nimport { ClassMigrations } from 'migrations'\n\n// First define your models as classes:\nexport class Product {\n  static properties = {\n    id: {\n      type: String,\n      primaryKey: true,\n    },\n    createdAt: {\n      type: Date,\n    },\n    name: {\n      type: String,\n    },\n    price: {\n      type: Number,\n    },\n    data: {\n      type: Object, // Use Object for JSON fields.\n    },\n  }\n}\n```\n\nThen run the migrations:\n\n```js\n// Then use this to create your migrations:\nlet migrations = new ClassMigrations(env.D1, [Product])\nawait migrations.run()\n```\n\nIf you add new properties, the database will automatically update on the next time you run it.\n\n### Ensure you only run it once on startup\n\nUse this once function:\n\n```\n\n```\n\n### Indexes\n\nAdd an index property to the field.\n\n```js\n{\n  userId: {\n    type: String,\n    index: true,\n  },\n}\n```\n\nTo make it a unique index:\n\n```js\n{\n  userId: {\n    type: String,\n    index: {\n      unique: true,\n    },\n  },\n}\n```\n\n## Using raw statements\n\n```js\nimport { Migrations } from 'migrations'\n\nlet migrations = new Migrations(db)\n// add all your migrations, one statement per add()\n// WARNING: DO NOT REMOVE A MIGRATION, EVER! JUST LEAVE THEM AND ADD TO THE LIST\nmigrations.add(`CREATE TABLE IF NOT EXISTS mytable (id string PRIMARY KEY, createdAt text)`)\nmigrations.add(`CREATE TABLE IF NOT EXISTS mytable2 (id string PRIMARY KEY, createdAt text)`)\n\n// Then run it. You can run this any number of times, it will only run each migration once.\nawait migrations.run()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeder%2Fmigrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreeder%2Fmigrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeder%2Fmigrations/lists"}