npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prisma-to-ecto

v0.0.2

Published

Convert Prisma schema to Ecto schema with migrations

Readme

prisma-to-ecto

Convert Prisma schemas into Elixir Ecto schemas and migrations.

prisma-to-ecto is a CLI tool that reads a Prisma schema.prisma file and generates:

  • Ecto schemas (.ex)
  • Ecto migrations (.exs)
  • Enum modules
  • Join tables for implicit many-to-many relations
  • View schema stubs

It helps teams migrating from Prisma → Elixir / Phoenix / Ecto or maintaining a Prisma-first schema workflow.


Installation

Global Installation (Recommended)

npm install -g prisma-to-ecto

Run the CLI:

prisma-to-ecto convert

Local Installation

Install inside your project:

npm install --save-dev prisma-to-ecto

Run using npx:

npx prisma-to-ecto convert

Project Structure

Your project only needs the Prisma schema.

Example:

my-project/
├── prisma/
│   └── schema.prisma
├── lib/
│   └── my_app/
├── priv/
│   └── repo/
│       └── migrations/
└── package.json

Only prisma/schema.prisma is required.


Place Your Prisma Schema

Create the Prisma directory if it doesn't exist:

mkdir -p prisma

Place your schema at:

prisma/schema.prisma

Running the Converter

Default Conversion

npx prisma-to-ecto convert

Default output:

Schema: ./prisma/schema.prisma
Schemas → ./prisma-to-ecto/schemas
Migrations → ./prisma-to-ecto/migrations

Custom Output Directories

npx prisma-to-ecto convert ./prisma/schema.prisma \
  --schema-out ./lib/my_app \
  --migration-out ./priv/repo/migrations

Generate Schemas Only

npx prisma-to-ecto convert --no-migrations

Generate Migrations Only

npx prisma-to-ecto convert --no-schemas

CLI Help

npx prisma-to-ecto --help

Example Output

prisma-to-ecto
  Schema:    ./prisma/schema.prisma
  Schemas →  ./lib/my_app
  Migrations → ./priv/repo/migrations

Parsed 20 model(s), 8 enum(s)

Generating Ecto schemas...
  ✓ user.ex
  ✓ task.ex
  ✓ project_stats.ex
  ... (28 total files)

Generating migrations...
  ✓ ..._create_users.exs
  ✓ ..._create_tasks.exs
  ✓ ..._create_label_task.exs
  ... (23 total files)

✓ Done!

Generated Files

Example structure:

lib/my_app/
├── user.ex
├── task.ex
├── notification_preference.ex
├── audit_log.ex
└── user_role.ex

priv/repo/migrations/
├── ..._create_users.exs
├── ..._create_tasks.exs
├── ..._create_label_task.exs
└── ..._create_view_project_statses.exs

Supported Prisma Features

The converter supports advanced Prisma schema features.

| Feature | Example | | ------------------------- | -------------------------------- | | UUID primary keys | @id @default(uuid()) | | Database schemas | @@schema("auth") | | Referential actions | Cascade, SetNull, Restrict | | Named relations | Task.assignee, Task.reporter | | Self-referential models | Task.subtasks | | Database annotations | @db.VarChar(320) | | Full-text indexes | @@fulltext | | Enum mapping | @map | | Composite primary keys | @@id([userId, channel]) | | Custom table names | @@map | | Views | view ProjectStats | | BigInt | Attachment.sizeBytes | | Decimal | Invoice.amountCents | | JSON fields | Json | | Implicit many-to-many | Task ↔ Label | | Sensitive field detection | password / secret / token |


Manual Review After Conversion

The generator may add TODO comments for items requiring manual review.

| Item | Location | Action | | -------------- | -------------------- | --------------------------------------- | | Foreign keys | User.assignedTasks | Set correct foreign_key: | | Database views | View migration | Write SQL query | | Enums | Migrations | Create Postgres enum type or use string |


Example package.json Script

Add a shortcut command:

{
  "scripts": {
    "convert": "prisma-to-ecto convert"
  }
}

Run with:

npm run convert

Using With Phoenix / Ecto

After generating migrations:

mix ecto.migrate

License

MIT