Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tegral PrismaKT: Prisma integration with JetBrains Exposed #81

Open
3 of 11 tasks
utybo opened this issue Apr 24, 2023 · 0 comments
Open
3 of 11 tasks

Tegral PrismaKT: Prisma integration with JetBrains Exposed #81

utybo opened this issue Apr 24, 2023 · 0 comments
Assignees
Labels
experiments This issue or PR is about an experimental (or would-be experimental) feature Module: new module
Milestone

Comments

@utybo
Copy link
Owner

utybo commented Apr 24, 2023

Hi to whoever will read this, long time no see! I'm back and am finally able to reveal some stuff I've been working on in the past months.

Tegral PrismaKT

Tegral PrismaKT is a module that generates JetBrains Exposed DAOs and table definitions from your Prisma schema.

In short, automatically get from this:

generator prismakt {
  provider      = "gradle --console=plain -q runGeneratorInternal"
  output        = "../build/prismaGeneratedSrc"
  exposedTarget = "sql" // or dao
}

datasource db {
  provider = "postgresql"
  url      = "file:./dev.db"
}

model User {
  identifier Int     @id @default(autoincrement())
  email      String  @unique
  name       String?
}

To this:

public object UserTable : IdTable<Int>() {
  public val email: Column<String> = text(name = "email")

  public val name: Column<String?> = text(name = "name").nullable()

  public val identifier: Column<EntityID<Int>> = integer(name = "identifier").entityId()

  public override val id: Column<EntityID<Int>>
    get() = identifier
}

public class UserEntity(
  id: EntityID<Int>,
) : Entity<Int>(id) {
  public var email: String by UserTable.email

  public var name: String? by UserTable.name

  public companion object : EntityClass<Int, UserEntity>(UserTable)
}

It integrates into Prisma's existing "generator" concept and generates classes via Prisma's datamodel (DMMF). For more information, check Prisma's article here. Massive thanks to the work done by YassinEldeeb on create-prisma-generator that allowed me to get good documentation on how to do things :)

Status

This will be a "long-life" issue which tracks the progress on PrismaKT. Due to the high complexity of what Prisma can handle, there will be a fairly long period spent debugging things PrismaKT gets totally wrong.

Expected initial release for 0.0.4 along with Tegral Niwen (which is required for this issue)

Initial release: 0.0.4 (planned)

  • Basic support for Prisma files and JetBrains Exposed SQL or DAO + SQL.
  • Documentation on how to integrate PrismaKT
  • A basic testsuite that covers most edge cases

Next release: 0.0.5

For alpha release

For beta release

  • JSON column support
  • Integration with Tegral DI and Tegral Web

For stable release

  • Ktorm support?
@utybo utybo added experiments This issue or PR is about an experimental (or would-be experimental) feature Module: new module labels Apr 24, 2023
@utybo utybo added this to the 0.0.4 milestone Apr 24, 2023
@utybo utybo self-assigned this Apr 24, 2023
@utybo utybo modified the milestones: 0.0.4, 0.0.5 May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiments This issue or PR is about an experimental (or would-be experimental) feature Module: new module
Projects
None yet
Development

No branches or pull requests

1 participant