{"id":19683904,"url":"https://github.com/prisma/prisma-platformatic","last_synced_at":"2025-04-29T05:31:34.192Z","repository":{"id":118534441,"uuid":"547441394","full_name":"prisma/prisma-platformatic","owner":"prisma","description":"Prisma 💚 Platformatic exploration","archived":false,"fork":false,"pushed_at":"2024-01-10T07:10:22.000Z","size":797,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T11:00:03.713Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-07T17:34:40.000Z","updated_at":"2024-01-10T10:06:39.000Z","dependencies_parsed_at":"2023-12-23T17:12:55.445Z","dependency_job_id":null,"html_url":"https://github.com/prisma/prisma-platformatic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-platformatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-platformatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-platformatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma-platformatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/prisma-platformatic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251444540,"owners_count":21590516,"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":[],"created_at":"2024-11-11T18:16:01.798Z","updated_at":"2025-04-29T05:31:33.864Z","avatar_url":"https://github.com/prisma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Platformatic Prisma integration\n\nArticle series:\n- [Part 1: Why Prisma and Platformatic are a great match ](https://dev.to/prisma/why-prisma-and-platformatic-are-a-great-match-2dkl)\n- [Part 2: Friendly Data Modeling \u0026 Auto-generated, Editable Migrations for Platformatic with Prisma](https://dev.to/prisma/friendly-data-modeling-auto-generated-editable-migrations-for-platformatic-with-prisma-dib)\n- [Part 3: Extend your Platformatic API with Prisma Client](https://dev.to/prisma/extend-your-platformatic-api-with-prisma-client-3p92)\n\n\n## Usage\n\nClone the repository\n\n```\ngit clone git@github.com:ruheni/prisma-platformatic.git\n```\n\nInstall dependencies\n```\ncd prisma-platformatic\nnpm i\n```\n\nStart up the container with docker compose:\n```\ndocker-compose up -d\n```\n\nCreate a `.env` file at the root of your project directory:\n\n```\ncp .env.example .env\n```\n\nOpen up the [`schema.prisma`](./prisma/schema.prisma) file. The schema contains two models: `User` and `Post`. The `User` and `Post` model have a 1-n relationship.\n\n```prisma\nmodel User {\n  id    Int     @id @default(autoincrement())\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n\nmodel Post {\n  id        Int      @id @default(autoincrement())\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  title     String\n  content   String?\n  published Boolean  @default(false)\n  viewCount Int      @default(0)\n  author    User?    @relation(fields: [authorId], references: [id])\n  authorId  Int?\n}\n```\n\nGenerate a migration using [`@ruheni/db-diff`](https://github.com/ruheni/db-diff):\n```\nnpx db-diff\n```\n\nThe command will generate an `up` and a `down` migration, i.e. `001.do.sql` and `001.undo.sql`, which are Postgrator-compatible.\n\n\u003e `@ruheni/db-diff` is a helper library built on top of the Prisma CLI for auto-generating, versioning, fully-customizable database migrations that are Postgrator-compatible. By default, it generates both `up` and `down` migrations. Check out the [README](https://github.com/ruheni/db-diff/blob/main/README.md) to learn more about it.\n\n\nApply the migration:\n\n```\nnpx platformatic db migrate\n```\n\nUnder the hood, Platformatic will create a `versions` table in the database. The `versions` table is used by Platformatic(that uses [Postgrator]() under the hood) to track the applied migrations to your database. The next time you run `npx db-diff`, it will generate SQL that will prompt you to drop the table from your database. This is an undesirable behavior. Therefore, add the following snippet to your Prisma schema file to prevent this from happening:\n\n```prisma\n// used by [postgrator](https://github.com/rickbergfalk/postgrator) to keep track of applied migrations\nmodel versions {\n  version BigInt    @id\n  name    String?\n  md5     String?\n  run_at  DateTime? @db.Timestamptz(6)\n\n  @@ignore\n}\n```\n\nStart-up Platformatic DB:\n```\nnpm run dev\n```\n\nExplore the GraphQL API on [http://localhost:3042/graphiql](http://localhost:3042/graphiql).\nExplore the REST API documentation at [http://localhost:3042/documentation](http://localhost:3042/documentation).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma-platformatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fprisma-platformatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma-platformatic/lists"}