prisma / database-schema-examples

Database Schema Examples we strive to support in Prisma
214 stars 49 forks source link

Add ghost schema #101

Closed 2color closed 4 years ago

2color commented 4 years ago

Introspection works.

Resulting schema.prisma:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = "mysql://root:OBFUSCATED@127.0.0.1:3306/ghost"
}

model actions {
  actor_id      String
  actor_type    String
  context       String?
  created_at    DateTime
  event         String
  id            String   @id
  resource_id   String?
  resource_type String
}

model api_keys {
  created_at        DateTime
  created_by        String
  id                String    @id
  integration_id    String?
  last_seen_at      DateTime?
  last_seen_version String?
  role_id           String?
  secret            String    @unique
  type              String
  updated_at        DateTime?
  updated_by        String?
}

model apps {
  created_at   DateTime
  created_by   String
  id           String         @id
  name         String         @unique
  slug         String         @unique
  status       String         @default("inactive")
  updated_at   DateTime?
  updated_by   String?
  version      String
  app_fields   app_fields[]
  app_settings app_settings[]
}

model app_fields {
  active         Boolean   @default(true)
  created_at     DateTime
  created_by     String
  id             String    @id
  key            String
  relatable_id   String
  relatable_type String    @default("posts")
  type           String    @default("html")
  updated_at     DateTime?
  updated_by     String?
  value          String?
  app_id         apps

  @@index([app_id], name: "app_fields_app_id_foreign")
}

model app_settings {
  created_at DateTime
  created_by String
  id         String    @id
  key        String    @unique
  updated_at DateTime?
  updated_by String?
  value      String?
  app_id     apps

  @@index([app_id], name: "app_settings_app_id_foreign")
}

/// The underlying table does not contain a unique identifier and can therefore currently not be handled.
// model brute {
  // count        Int
  // firstRequest Int
  // key          String
  // lastRequest  Int
  // lifetime     Int
// }

model emails {
  created_at   DateTime
  created_by   String
  email_count  Int       @default(0)
  error        String?
  error_data   String?
  html         String?
  id           String    @id
  meta         String?
  plaintext    String?
  post_id      String    @unique
  stats        String?
  status       String    @default("pending")
  subject      String?
  submitted_at DateTime
  updated_at   DateTime?
  updated_by   String?
  uuid         String

  @@index([post_id], name: "emails_post_id_index")
}

model integrations {
  created_at  DateTime
  created_by  String
  description String?
  icon_image  String?
  id          String    @id
  name        String
  slug        String    @unique
  type        String    @default("custom")
  updated_at  DateTime?
  updated_by  String?
}

model invites {
  created_at DateTime
  created_by String
  email      String    @unique
  expires    Int
  id         String    @id
  role_id    String
  status     String    @default("pending")
  token      String    @unique
  updated_at DateTime?
  updated_by String?
}

model labels {
  created_at     DateTime
  created_by     String
  id             String           @id
  name           String           @unique
  slug           String           @unique
  updated_at     DateTime?
  updated_by     String?
  members_labels members_labels[]
}

model members {
  created_at     DateTime
  created_by     String
  email          String           @unique
  id             String           @id
  name           String?
  note           String?
  subscribed     Boolean?         @default(true)
  updated_at     DateTime?
  updated_by     String?
  uuid           String?          @unique
  members_labels members_labels[]
}

model members_labels {
  id         String  @id
  sort_order Int     @default(0)
  label_id   labels
  member_id  members

  @@index([label_id], name: "members_labels_label_id_foreign")
  @@index([member_id], name: "members_labels_member_id_foreign")
}

model members_stripe_customers {
  created_at  DateTime
  created_by  String
  customer_id String
  email       String?
  id          String    @id
  member_id   String
  name        String?
  updated_at  DateTime?
  updated_by  String?
}

model members_stripe_customers_subscriptions {
  cancel_at_period_end       Boolean   @default(false)
  created_at                 DateTime
  created_by                 String
  current_period_end         DateTime
  customer_id                String
  default_payment_card_last4 String?
  id                         String    @id
  plan_amount                Int
  plan_currency              String
  plan_id                    String
  plan_interval              String
  plan_nickname              String
  start_date                 DateTime
  status                     String
  subscription_id            String
  updated_at                 DateTime?
  updated_by                 String?
}

model migrations {
  currentVersion String?
  id             Int     @default(autoincrement()) @id
  name           String
  version        String

  @@unique([name, version], name: "migrations_name_version_unique")
}

model migrations_lock {
  acquired_at DateTime?
  locked      Boolean?  @default(false)
  lock_key    String    @unique
  released_at DateTime?
}

model mobiledoc_revisions {
  created_at    DateTime
  created_at_ts Int
  id            String   @id
  mobiledoc     String?
  post_id       String

  @@index([post_id], name: "mobiledoc_revisions_post_id_index")
}

model permissions {
  action_type String
  created_at  DateTime
  created_by  String
  id          String    @id
  name        String    @unique
  object_id   String?
  object_type String
  updated_at  DateTime?
  updated_by  String?
}

model permissions_apps {
  app_id        String
  id            String @id
  permission_id String
}

model permissions_roles {
  id            String @id
  permission_id String
  role_id       String
}

model permissions_users {
  id            String @id
  permission_id String
  user_id       String
}

model posts {
  author_id                 String
  canonical_url             String?
  codeinjection_foot        String?
  codeinjection_head        String?
  comment_id                String?
  created_at                DateTime
  created_by                String
  custom_excerpt            String?
  custom_template           String?
  featured                  Boolean         @default(false)
  feature_image             String?
  html                      String?
  id                        String          @id
  locale                    String?
  mobiledoc                 String?
  plaintext                 String?
  published_at              DateTime?
  published_by              String?
  send_email_when_published Boolean?        @default(false)
  slug                      String          @unique
  status                    String          @default("draft")
  title                     String
  type                      String          @default("post")
  updated_at                DateTime?
  updated_by                String?
  uuid                      String
  visibility                String          @default("public")
  posts_authors             posts_authors[]
  posts_meta                posts_meta?
  posts_tags                posts_tags[]
}

model posts_authors {
  id         String @id
  sort_order Int    @default(0)
  author_id  users
  post_id    posts

  @@index([author_id], name: "posts_authors_author_id_foreign")
  @@index([post_id], name: "posts_authors_post_id_foreign")
}

model posts_meta {
  email_subject       String?
  id                  String  @id
  meta_description    String?
  meta_title          String?
  og_description      String?
  og_image            String?
  og_title            String?
  twitter_description String?
  twitter_image       String?
  twitter_title       String?
  post_id             posts
}

model posts_tags {
  id         String @id
  sort_order Int    @default(0)
  post_id    posts
  tag_id     tags

  @@index([post_id], name: "posts_tags_post_id_foreign")
  @@index([tag_id], name: "posts_tags_tag_id_foreign")
}

model roles {
  created_at  DateTime
  created_by  String
  description String?
  id          String    @id
  name        String    @unique
  updated_at  DateTime?
  updated_by  String?
}

model roles_users {
  id      String @id
  role_id String
  user_id String
}

model sessions {
  created_at   DateTime
  id           String    @id
  session_data String
  session_id   String    @unique
  updated_at   DateTime?
  user_id      String
}

model settings {
  created_at DateTime
  created_by String
  id         String    @id
  key        String    @unique
  type       String    @default("core")
  updated_at DateTime?
  updated_by String?
  value      String?
}

model tags {
  created_at       DateTime
  created_by       String
  description      String?
  feature_image    String?
  id               String       @id
  meta_description String?
  meta_title       String?
  name             String
  parent_id        String?
  slug             String       @unique
  updated_at       DateTime?
  updated_by       String?
  visibility       String       @default("public")
  posts_tags       posts_tags[]
}

model users {
  accessibility    String?
  bio              String?
  cover_image      String?
  created_at       DateTime
  created_by       String
  email            String          @unique
  facebook         String?
  id               String          @id
  last_seen        DateTime?
  locale           String?
  location         String?
  meta_description String?
  meta_title       String?
  name             String
  password         String
  profile_image    String?
  slug             String          @unique
  status           String          @default("active")
  tour             String?
  twitter          String?
  updated_at       DateTime?
  updated_by       String?
  visibility       String          @default("public")
  website          String?
  posts_authors    posts_authors[]
}

model webhooks {
  api_version           String    @default("v2")
  created_at            DateTime
  created_by            String
  event                 String
  id                    String    @id
  integration_id        String?
  last_triggered_at     DateTime?
  last_triggered_error  String?
  last_triggered_status String?
  name                  String?
  secret                String?
  status                String    @default("available")
  target_url            String
  updated_at            DateTime?
  updated_by            String?
}