Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

SyntaxError: Unexpected identifier #559

Closed
albertoperdomo opened this issue Mar 10, 2020 · 4 comments
Closed

SyntaxError: Unexpected identifier #559

albertoperdomo opened this issue Mar 10, 2020 · 4 comments
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.

Comments

@albertoperdomo
Copy link

//import { PrismaClient } from '@prisma/client'
const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

prisma.api_keys.findMany({ first: 10 })
  .then(api_keys => console.log(api_keys))

Database: Postgres / Discourse
Schema: Introspected from database (can provide if needed)

Error:

~/Code/prisma/test  node test.js                                                       ✔  218  14:38:15
/Users/alberto/Code/prisma/test/node_modules/@prisma/client/index.js:39484
const dmmfString = '{"datamodel":{"enums":[],"models":[{"name":"api_keys","isEmbedded":false,"dbName":null,"fields":[{"name":"allowed_ips","kind":"scalar","dbNames":[],"isList":true,"isRequired":false,"isUnique":false,"isId":false,"type":"String","isGenerated":false,"isUpdatedAt":false},{"name":"created_at","kind":"scalar","dbNames":[],"isList":false,"isRequired":true,"isUnique":false,"isId":false,"type":"DateTime","isGenerated":false,"isUpdatedAt":false},{"name":"created_by_id","kind":"scalar","dbNames":[],"isList":false,"isRequired":false,"isUnique":false,"isId":false,"type":"Int","isGenerated":false,"isUpdatedAt":false},{"name":"hidden","kind":"scalar","dbNames":[],"isList":false,"isRequired":true,"isUnique":false,"isId":false,"type":"Boolean","default":false,"isGenerated":false,"isUpdatedAt":false},{"name":"id","kind":"scalar","dbNames":[],"isList":false,"isRequired":true,"isUnique":false,"isId":true,"type":"Int","default":{"name

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/alberto/Code/prisma/test/test.js:2:26)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)

Environment

prisma2@2.0.0-preview023, binary version: d3b0ceed5d87544b9d2decb70e08664f9047bb73
Node
Node v12.12.0
@janpio
Copy link
Member

janpio commented Mar 10, 2020

Where does this const dmmfString = ... output come from?

@janpio janpio self-assigned this Mar 10, 2020
@janpio
Copy link
Member

janpio commented Mar 10, 2020

This is actually reproducible with this test.js:

const { PrismaClient } = require('@prisma/client')

Reproduction here: https://github.com/janpio/albertoRepro

@janpio janpio removed their assignment Mar 10, 2020
@Jolg42 Jolg42 added the bug/2-confirmed We have confirmed that this is a bug. label Mar 10, 2020
@janpio
Copy link
Member

janpio commented Mar 10, 2020

@Jolg42 helped us understand that something in the dmmf is making the client crash. Turns out the fields have strings as default it does not like at all.

Replaced by prisma/prisma#1810

@janpio janpio closed this as completed Mar 10, 2020
@Jolg42 Jolg42 added the kind/bug A reported bug. label Mar 10, 2020
@janpio
Copy link
Member

janpio commented Mar 10, 2020

Solution for @albertoperdomo:

Remove all the :: strings to get this schema:

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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model api_keys {
  allowed_ips   String[]
  created_at    DateTime
  created_by_id Int?
  hidden        Boolean  @default(false)
  id            Int      @default(autoincrement()) @id
  key           String
  updated_at    DateTime
  user_id       Int?     @unique

  @@index([key], name: "index_api_keys_on_key")
}

model application_requests {
  count    Int      @default(0)
  date     DateTime
  id       Int      @default(autoincrement()) @id
  req_type Int

  @@unique([date, req_type], name: "index_application_requests_on_date_and_req_type")
}

model ar_internal_metadata {
  created_at DateTime
  key        String   @id
  updated_at DateTime
  value      String?
}

model badge_groupings {
  created_at  DateTime
  description String?
  id          Int      @default(autoincrement()) @id
  name        String
  position    Int
  updated_at  DateTime
}

model badges {
  allow_title       Boolean  @default(false)
  auto_revoke       Boolean  @default(true)
  badge_grouping_id Int      @default(5)
  badge_type_id     Int
  created_at        DateTime
  description       String?
  enabled           Boolean  @default(true)
  grant_count       Int      @default(0)
  icon              String?  @default("fa-certificate")
  id                Int      @default(autoincrement()) @id
  image             String?
  listable          Boolean? @default(true)
  long_description  String?
  multiple_grant    Boolean  @default(false)
  name              String   @unique
  query             String?
  show_posts        Boolean  @default(false)
  system            Boolean  @default(false)
  target_posts      Boolean? @default(false)
  trigger           Int?
  updated_at        DateTime

  @@index([badge_type_id], name: "index_badges_on_badge_type_id")
}

model badge_types {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  name       String   @unique
  updated_at DateTime
}

model categories {
  allow_badges                      Boolean  @default(true)
  all_topics_wiki                   Boolean  @default(false)
  auto_close_based_on_last_post     Boolean? @default(false)
  auto_close_hours                  Float?
  color                             String   @default("AB9364")
  contains_messages                 Boolean?
  created_at                        DateTime
  default_top_period                String?  @default("all")
  default_view                      String?
  description                       String?
  email_in                          String?  @unique
  email_in_allow_strangers          Boolean? @default(false)
  id                                Int      @default(autoincrement()) @id
  latest_post_id                    Int?
  latest_topic_id                   Int?
  mailinglist_mirror                Boolean  @default(false)
  minimum_required_tags             Int?     @default(0)
  name                              String   @unique
  name_lower                        String
  navigate_to_first_post_after_read Boolean  @default(false)
  num_featured_topics               Int?     @default(3)
  parent_category_id                Int?
  position                          Int?
  post_count                        Int      @default(0)
  posts_day                         Int?     @default(0)
  posts_month                       Int?     @default(0)
  posts_week                        Int?     @default(0)
  posts_year                        Int?     @default(0)
  read_restricted                   Boolean  @default(false)
  show_subcategory_list             Boolean? @default(false)
  slug                              String
  sort_ascending                    Boolean?
  sort_order                        String?
  subcategory_list_style            String?  @default("rows_with_featured_topics")
  suppress_from_latest              Boolean? @default(false)
  text_color                        String   @default("FFFFFF")
  topic_count                       Int      @default(0)
  topic_featured_link_allowed       Boolean? @default(true)
  topic_id                          Int?
  topics_day                        Int?     @default(0)
  topics_month                      Int?     @default(0)
  topics_week                       Int?     @default(0)
  topics_year                       Int?     @default(0)
  topic_template                    String?
  updated_at                        DateTime
  uploaded_background_id            Int?
  uploaded_logo_id                  Int?
  user_id                           Int

  @@index([topic_count], name: "index_categories_on_topic_count")
}

model categories_web_hooks {
  category_id Int
  web_hook_id Int

  @@unique([web_hook_id, category_id], name: "index_categories_web_hooks_on_web_hook_id_and_category_id")
}

model category_custom_fields {
  category_id Int
  created_at  DateTime
  id          Int      @default(autoincrement()) @id
  name        String
  updated_at  DateTime
  value       String?

  @@index([category_id, name], name: "index_category_custom_fields_on_category_id_and_name")
}

model category_featured_topics {
  category_id Int
  created_at  DateTime
  id          Int      @default(autoincrement()) @id
  rank        Int      @default(0)
  topic_id    Int
  updated_at  DateTime

  @@index([category_id, rank], name: "index_category_featured_topics_on_category_id_and_rank")
  @@unique([category_id, topic_id], name: "cat_featured_threads")
}

model category_groups {
  category_id     Int
  created_at      DateTime
  group_id        Int
  id              Int      @default(autoincrement()) @id
  permission_type Int?     @default(1)
  updated_at      DateTime
}

model category_search_data {
  category_id Int     @id
  locale      String?
  raw_data    String?
  search_data String?
  version     Int?    @default(0)

  @@index([search_data], name: "idx_search_category")
}

model category_tag_groups {
  category_id  Int
  created_at   DateTime?
  id           Int       @default(autoincrement()) @id
  tag_group_id Int
  updated_at   DateTime?

  @@unique([category_id, tag_group_id], name: "idx_category_tag_groups_ix1")
}

model category_tags {
  category_id Int
  created_at  DateTime?
  id          Int       @default(autoincrement()) @id
  tag_id      Int
  updated_at  DateTime?

  @@unique([category_id, tag_id], name: "idx_category_tags_ix1")
  @@unique([tag_id, category_id], name: "idx_category_tags_ix2")
}

model category_tag_stats {
  category_id Int
  id          Int @default(autoincrement()) @id
  tag_id      Int
  topic_count Int @default(0)

  @@index([category_id], name: "index_category_tag_stats_on_category_id")
  @@index([category_id, topic_count], name: "index_category_tag_stats_on_category_id_and_topic_count")
  @@index([tag_id], name: "index_category_tag_stats_on_tag_id")
  @@unique([category_id, tag_id], name: "index_category_tag_stats_on_category_id_and_tag_id")
}

model category_users {
  category_id        Int
  id                 Int @default(autoincrement()) @id
  notification_level Int
  user_id            Int

  @@unique([user_id, category_id, notification_level], name: "idx_category_users_u1")
  @@unique([category_id, user_id, notification_level], name: "idx_category_users_u2")
}

model child_themes {
  child_theme_id  Int?
  created_at      DateTime?
  id              Int       @default(autoincrement()) @id
  parent_theme_id Int?
  updated_at      DateTime?

  @@unique([child_theme_id, parent_theme_id], name: "index_child_themes_on_child_theme_id_and_parent_theme_id")
  @@unique([parent_theme_id, child_theme_id], name: "index_child_themes_on_parent_theme_id_and_child_theme_id")
}

model color_scheme_colors {
  color_scheme_id Int
  created_at      DateTime
  hex             String
  id              Int      @default(autoincrement()) @id
  name            String
  updated_at      DateTime

  @@index([color_scheme_id], name: "index_color_scheme_colors_on_color_scheme_id")
}

model color_schemes {
  base_scheme_id String?
  created_at     DateTime
  id             Int      @default(autoincrement()) @id
  name           String
  theme_id       Int?
  updated_at     DateTime
  version        Int      @default(1)
  via_wizard     Boolean  @default(false)
}

model custom_emojis {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  name       String   @unique
  updated_at DateTime
  upload_id  Int
}

model developers {
  id      Int @default(autoincrement()) @id
  user_id Int
}

model directory_items {
  created_at     DateTime?
  days_visited   Int       @default(0)
  id             Int       @default(autoincrement()) @id
  likes_given    Int
  likes_received Int
  period_type    Int
  post_count     Int
  posts_read     Int       @default(0)
  topic_count    Int
  topics_entered Int
  updated_at     DateTime?
  user_id        Int

  @@index([days_visited], name: "index_directory_items_on_days_visited")
  @@index([likes_given], name: "index_directory_items_on_likes_given")
  @@index([likes_received], name: "index_directory_items_on_likes_received")
  @@index([post_count], name: "index_directory_items_on_post_count")
  @@index([posts_read], name: "index_directory_items_on_posts_read")
  @@index([topic_count], name: "index_directory_items_on_topic_count")
  @@index([topics_entered], name: "index_directory_items_on_topics_entered")
  @@unique([period_type, user_id], name: "index_directory_items_on_period_type_and_user_id")
}

model drafts {
  created_at DateTime
  data       String
  draft_key  String
  id         Int      @default(autoincrement()) @id
  revisions  Int      @default(1)
  sequence   Int      @default(0)
  updated_at DateTime
  user_id    Int

  @@index([user_id, draft_key], name: "index_drafts_on_user_id_and_draft_key")
}

model draft_sequences {
  draft_key String
  id        Int    @default(autoincrement()) @id
  sequence  Int
  user_id   Int

  @@unique([user_id, draft_key], name: "index_draft_sequences_on_user_id_and_draft_key")
}

model email_change_requests {
  change_state       Int
  created_at         DateTime
  id                 Int      @default(autoincrement()) @id
  new_email          String
  new_email_token_id Int?
  old_email          String
  old_email_token_id Int?
  updated_at         DateTime
  user_id            Int

  @@index([user_id], name: "index_email_change_requests_on_user_id")
}

model email_logs {
  bounced    Boolean  @default(false)
  bounce_key String?
  created_at DateTime
  email_type String
  id         Int      @default(autoincrement()) @id
  message_id String?
  post_id    Int?
  to_address String
  updated_at DateTime
  user_id    Int?

  @@index([bounced], name: "index_email_logs_on_bounced")
  @@index([created_at], name: "index_email_logs_on_created_at")
  @@index([message_id], name: "index_email_logs_on_message_id")
  @@index([post_id], name: "index_email_logs_on_post_id")
  @@index([user_id], name: "index_email_logs_on_user_id")
}

model email_tokens {
  confirmed  Boolean  @default(false)
  created_at DateTime
  email      String
  expired    Boolean  @default(false)
  id         Int      @default(autoincrement()) @id
  token      String   @unique
  updated_at DateTime
  user_id    Int

  @@index([user_id], name: "index_email_tokens_on_user_id")
}

model embeddable_hosts {
  category_id    Int
  class_name     String?
  created_at     DateTime?
  host           String
  id             Int       @default(autoincrement()) @id
  path_whitelist String?
  updated_at     DateTime?
}

model facebook_user_infos {
  about_me         String?
  avatar_url       String?
  created_at       DateTime
  email            String?
  facebook_user_id Int      @unique
  first_name       String?
  gender           String?
  id               Int      @default(autoincrement()) @id
  last_name        String?
  link             String?
  location         String?
  name             String?
  updated_at       DateTime
  user_id          Int      @unique
  username         String?
  website          String?
}

model github_user_infos {
  created_at     DateTime
  github_user_id Int      @unique
  id             Int      @default(autoincrement()) @id
  screen_name    String
  updated_at     DateTime
  user_id        Int      @unique
}

model given_daily_likes {
  given_date    DateTime
  likes_given   Int
  limit_reached Boolean  @default(false)
  user_id       Int

  @@index([limit_reached, user_id], name: "index_given_daily_likes_on_limit_reached_and_user_id")
  @@unique([user_id, given_date], name: "index_given_daily_likes_on_user_id_and_given_date")
}

model google_user_infos {
  created_at     DateTime
  email          String?
  first_name     String?
  gender         String?
  google_user_id String   @unique
  id             Int      @default(autoincrement()) @id
  last_name      String?
  link           String?
  name           String?
  picture        String?
  profile_link   String?
  updated_at     DateTime
  user_id        Int      @unique
}

model group_archived_messages {
  created_at DateTime?
  group_id   Int
  id         Int       @default(autoincrement()) @id
  topic_id   Int
  updated_at DateTime?

  @@unique([group_id, topic_id], name: "index_group_archived_messages_on_group_id_and_topic_id")
}

model group_custom_fields {
  created_at DateTime
  group_id   Int
  id         Int      @default(autoincrement()) @id
  name       String
  updated_at DateTime
  value      String?

  @@index([group_id, name], name: "index_group_custom_fields_on_group_id_and_name")
}

model group_histories {
  acting_user_id Int
  action         Int
  created_at     DateTime
  group_id       Int
  id             Int      @default(autoincrement()) @id
  new_value      String?
  prev_value     String?
  subject        String?
  target_user_id Int?
  updated_at     DateTime

  @@index([acting_user_id], name: "index_group_histories_on_acting_user_id")
  @@index([action], name: "index_group_histories_on_action")
  @@index([group_id], name: "index_group_histories_on_group_id")
  @@index([target_user_id], name: "index_group_histories_on_target_user_id")
}

model group_mentions {
  created_at DateTime?
  group_id   Int?
  id         Int       @default(autoincrement()) @id
  post_id    Int?
  updated_at DateTime?

  @@unique([group_id, post_id], name: "index_group_mentions_on_group_id_and_post_id")
  @@unique([post_id, group_id], name: "index_group_mentions_on_post_id_and_group_id")
}

model groups {
  allow_membership_requests          Boolean  @default(false)
  automatic                          Boolean  @default(false)
  automatic_membership_email_domains String?
  automatic_membership_retroactive   Boolean? @default(false)
  bio_cooked                         String?
  bio_raw                            String?
  created_at                         DateTime
  default_notification_level         Int      @default(3)
  flair_bg_color                     String?
  flair_color                        String?
  flair_url                          String?
  full_name                          String?
  grant_trust_level                  Int?
  has_messages                       Boolean  @default(false)
  id                                 Int      @default(autoincrement()) @id
  incoming_email                     String?  @unique
  membership_request_template        String?
  mentionable_level                  Int?     @default(0)
  messageable_level                  Int?     @default(0)
  name                               String   @unique
  primary_group                      Boolean  @default(false)
  public_admission                   Boolean  @default(false)
  public_exit                        Boolean  @default(false)
  title                              String?
  updated_at                         DateTime
  user_count                         Int      @default(0)
  visibility_level                   Int      @default(0)
}

model groups_web_hooks {
  group_id    Int
  web_hook_id Int

  @@unique([web_hook_id, group_id], name: "index_groups_web_hooks_on_web_hook_id_and_group_id")
}

model group_users {
  created_at         DateTime
  group_id           Int
  id                 Int      @default(autoincrement()) @id
  notification_level Int      @default(2)
  owner              Boolean  @default(false)
  updated_at         DateTime
  user_id            Int

  @@unique([group_id, user_id], name: "index_group_users_on_group_id_and_user_id")
  @@unique([user_id, group_id], name: "index_group_users_on_user_id_and_group_id")
}

model incoming_domains {
  https Boolean @default(false)
  id    Int     @default(autoincrement()) @id
  name  String
  port  Int

  @@unique([name, https, port], name: "index_incoming_domains_on_name_and_https_and_port")
}

model incoming_emails {
  cc_addresses      String?
  created_at        DateTime
  error             String?
  from_address      String?
  id                Int      @default(autoincrement()) @id
  is_auto_generated Boolean? @default(false)
  is_bounce         Boolean  @default(false)
  message_id        String?
  post_id           Int?
  raw               String?
  rejection_message String?
  subject           String?
  to_addresses      String?
  topic_id          Int?
  updated_at        DateTime
  user_id           Int?

  @@index([created_at], name: "index_incoming_emails_on_created_at")
  @@index([error], name: "index_incoming_emails_on_error")
  @@index([message_id], name: "index_incoming_emails_on_message_id")
  @@index([post_id], name: "index_incoming_emails_on_post_id")
}

model incoming_links {
  created_at          DateTime
  current_user_id     Int?
  id                  Int      @default(autoincrement()) @id
  incoming_referer_id Int?
  ip_address          String?
  post_id             Int
  user_id             Int?

  @@index([created_at, user_id], name: "index_incoming_links_on_created_at_and_user_id")
  @@index([post_id], name: "index_incoming_links_on_post_id")
}

model incoming_referers {
  id                 Int    @default(autoincrement()) @id
  incoming_domain_id Int
  path               String

  @@unique([path, incoming_domain_id], name: "index_incoming_referers_on_path_and_incoming_domain_id")
}

model instagram_user_infos {
  created_at        DateTime
  id                Int      @default(autoincrement()) @id
  instagram_user_id Int?
  screen_name       String?
  updated_at        DateTime
  user_id           Int?
}

model invited_groups {
  created_at DateTime
  group_id   Int?
  id         Int      @default(autoincrement()) @id
  invite_id  Int?
  updated_at DateTime
}

model invites {
  created_at     DateTime
  custom_message String?
  deleted_at     DateTime?
  deleted_by_id  Int?
  email          String?
  id             Int       @default(autoincrement()) @id
  invalidated_at DateTime?
  invited_by_id  Int
  invite_key     String    @unique
  moderator      Boolean   @default(false)
  redeemed_at    DateTime?
  updated_at     DateTime
  user_id        Int?

  @@index([email, invited_by_id], name: "index_invites_on_email_and_invited_by_id")
}

model javascript_caches {
  content        String
  created_at     DateTime
  digest         String?
  id             Int      @default(autoincrement()) @id
  theme_field_id Int
  updated_at     DateTime

  @@index([digest], name: "index_javascript_caches_on_digest")
  @@index([theme_field_id], name: "index_javascript_caches_on_theme_field_id")
}

model message_bus {
  context    String?
  created_at DateTime
  data       String?
  id         Int      @default(autoincrement()) @id
  name       String?

  @@index([created_at], name: "index_message_bus_on_created_at")
}

model muted_users {
  created_at    DateTime?
  id            Int       @default(autoincrement()) @id
  muted_user_id Int
  updated_at    DateTime?
  user_id       Int

  @@unique([muted_user_id, user_id], name: "index_muted_users_on_muted_user_id_and_user_id")
  @@unique([user_id, muted_user_id], name: "index_muted_users_on_user_id_and_muted_user_id")
}

model notifications {
  created_at        DateTime
  data              String
  id                Int      @default(autoincrement()) @id
  notification_type Int
  post_action_id    Int?
  post_number       Int?
  read              Boolean  @default(false)
  topic_id          Int?
  updated_at        DateTime
  user_id           Int

  @@index([user_id, notification_type], name: "idx_notifications_speedup_unread_count")
  @@index([post_action_id], name: "index_notifications_on_post_action_id")
  @@index([user_id, created_at], name: "index_notifications_on_user_id_and_created_at")
  @@index([user_id, topic_id, post_number], name: "index_notifications_on_user_id_and_topic_id_and_post_number")
  @@unique([user_id, id], name: "index_notifications_on_user_id_and_id")
}

model oauth2_user_infos {
  created_at DateTime
  email      String?
  id         Int      @default(autoincrement()) @id
  name       String?
  provider   String
  uid        String
  updated_at DateTime
  user_id    Int

  @@unique([uid, provider], name: "index_oauth2_user_infos_on_uid_and_provider")
}

model onceoff_logs {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  job_name   String?
  updated_at DateTime

  @@index([job_name], name: "index_onceoff_logs_on_job_name")
}

model optimized_images {
  extension String
  filesize  Int?
  height    Int
  id        Int    @default(autoincrement()) @id
  sha1      String
  upload_id Int
  url       String
  width     Int

  @@index([upload_id], name: "index_optimized_images_on_upload_id")
  @@unique([upload_id, width, height], name: "index_optimized_images_on_upload_id_and_width_and_height")
}

model permalinks {
  category_id  Int?
  created_at   DateTime?
  external_url String?
  id           Int       @default(autoincrement()) @id
  post_id      Int?
  topic_id     Int?
  updated_at   DateTime?
  url          String    @unique
}

model plugin_store_rows {
  id          Int     @default(autoincrement()) @id
  key         String
  plugin_name String
  type_name   String
  value       String?

  @@unique([plugin_name, key], name: "index_plugin_store_rows_on_plugin_name_and_key")
}

model post_actions {
  agreed_at           DateTime?
  agreed_by_id        Int?
  created_at          DateTime
  deferred_at         DateTime?
  deferred_by_id      Int?
  deleted_at          DateTime?
  deleted_by_id       Int?
  disagreed_at        DateTime?
  disagreed_by_id     Int?
  id                  Int       @default(autoincrement()) @id
  post_action_type_id Int
  post_id             Int
  related_post_id     Int?
  staff_took_action   Boolean   @default(false)
  targets_topic       Boolean   @default(false)
  updated_at          DateTime
  user_id             Int

  @@index([post_id], name: "index_post_actions_on_post_id")
  @@index([user_id, post_action_type_id], name: "index_post_actions_on_user_id_and_post_action_type_id")
  @@unique([user_id, post_action_type_id, post_id, targets_topic], name: "idx_unique_actions")
  @@unique([user_id, post_id, targets_topic], name: "idx_unique_flags")
}

model post_action_types {
  created_at DateTime
  icon       String?
  id         Int      @default(autoincrement()) @id
  is_flag    Boolean  @default(false)
  name_key   String
  position   Int      @default(0)
  updated_at DateTime
}

model post_custom_fields {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  name       String
  post_id    Int
  updated_at DateTime
  value      String?

  @@index([post_id], name: "idx_post_custom_fields_akismet")
  @@index([name], name: "index_post_custom_fields_on_name_and_value")
  @@index([post_id, name], name: "index_post_custom_fields_on_post_id_and_name")
}

model post_details {
  created_at DateTime
  extra      String?
  id         Int      @default(autoincrement()) @id
  key        String?
  post_id    Int?
  updated_at DateTime
  value      String?

  @@unique([post_id, key], name: "index_post_details_on_post_id_and_key")
}

model post_replies {
  created_at DateTime
  post_id    Int?
  reply_id   Int?
  updated_at DateTime

  @@unique([post_id, reply_id], name: "index_post_replies_on_post_id_and_reply_id")
}

model post_reply_keys {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  post_id    Int
  reply_key  String   @unique
  updated_at DateTime
  user_id    Int

  @@unique([user_id, post_id], name: "index_post_reply_keys_on_user_id_and_post_id")
}

model post_revisions {
  created_at    DateTime
  hidden        Boolean  @default(false)
  id            Int      @default(autoincrement()) @id
  modifications String?
  number        Int?
  post_id       Int?
  updated_at    DateTime
  user_id       Int?

  @@index([post_id], name: "index_post_revisions_on_post_id")
  @@index([post_id, number], name: "index_post_revisions_on_post_id_and_number")
}

model posts {
  action_code             String?
  avg_time                Int?
  baked_at                DateTime?
  baked_version           Int?
  bookmark_count          Int       @default(0)
  cooked                  String
  cook_method             Int       @default(1)
  created_at              DateTime
  deleted_at              DateTime?
  deleted_by_id           Int?
  edit_reason             String?
  hidden                  Boolean   @default(false)
  hidden_at               DateTime?
  hidden_reason_id        Int?
  id                      Int       @default(autoincrement()) @id
  illegal_count           Int       @default(0)
  image_url               String?
  inappropriate_count     Int       @default(0)
  incoming_link_count     Int       @default(0)
  last_editor_id          Int?
  last_version_at         DateTime
  like_count              Int       @default(0)
  like_score              Int       @default(0)
  locked_by_id            Int?
  notify_moderators_count Int       @default(0)
  notify_user_count       Int       @default(0)
  off_topic_count         Int       @default(0)
  percent_rank            Float?    @default(1)
  post_number             Int
  post_type               Int       @default(1)
  public_version          Int       @default(1)
  quote_count             Int       @default(0)
  raw                     String
  raw_email               String?
  reads                   Int       @default(0)
  reply_count             Int       @default(0)
  reply_quoted            Boolean   @default(false)
  reply_to_post_number    Int?
  reply_to_user_id        Int?
  score                   Float?
  self_edits              Int       @default(0)
  sort_order              Int?
  spam_count              Int       @default(0)
  topic_id                Int
  updated_at              DateTime
  user_deleted            Boolean   @default(false)
  user_id                 Int?
  version                 Int       @default(1)
  via_email               Boolean   @default(false)
  wiki                    Boolean   @default(false)
  word_count              Int?

  @@index([created_at, topic_id], name: "idx_posts_created_at_topic_id")
  @@index([topic_id, post_number], name: "idx_posts_deleted_posts")
  @@index([user_id], name: "idx_posts_user_id_deleted_at")
  @@index([reply_to_post_number], name: "index_posts_on_reply_to_post_number")
  @@index([topic_id, percent_rank], name: "index_posts_on_topic_id_and_percent_rank")
  @@index([topic_id, sort_order], name: "index_posts_on_topic_id_and_sort_order")
  @@index([user_id, created_at], name: "index_posts_on_user_id_and_created_at")
  @@unique([topic_id, post_number], name: "index_posts_on_topic_id_and_post_number")
}

model post_search_data {
  locale      String?
  post_id     Int     @id
  raw_data    String?
  search_data String?
  version     Int?    @default(0)

  @@index([search_data], name: "idx_search_post")
}

model post_stats {
  composer_open_duration_msecs Int?
  created_at                   DateTime?
  drafts_saved                 Int?
  id                           Int       @default(autoincrement()) @id
  post_id                      Int?
  typing_duration_msecs        Int?
  updated_at                   DateTime?

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

model post_timings {
  msecs       Int
  post_number Int
  topic_id    Int
  user_id     Int

  @@index([user_id], name: "index_post_timings_on_user_id")
  @@index([topic_id, post_number], name: "post_timings_summary")
  @@unique([topic_id, post_number, user_id], name: "post_timings_unique")
}

model post_uploads {
  id        Int @default(autoincrement()) @id
  post_id   Int
  upload_id Int

  @@index([post_id], name: "index_post_uploads_on_post_id")
  @@index([upload_id], name: "index_post_uploads_on_upload_id")
  @@unique([post_id, upload_id], name: "idx_unique_post_uploads")
}

model push_subscriptions {
  created_at DateTime
  data       String
  id         Int      @default(autoincrement()) @id
  updated_at DateTime
  user_id    Int
}

model queued_posts {
  approved_at    DateTime?
  approved_by_id Int?
  created_at     DateTime?
  id             Int       @default(autoincrement()) @id
  post_options   String
  queue          String
  raw            String
  rejected_at    DateTime?
  rejected_by_id Int?
  state          Int
  topic_id       Int?
  updated_at     DateTime?
  user_id        Int

  @@index([queue, state, created_at], name: "by_queue_status")
  @@index([topic_id, queue, state, created_at], name: "by_queue_status_topic")
}

model quoted_posts {
  created_at     DateTime
  id             Int      @default(autoincrement()) @id
  post_id        Int
  quoted_post_id Int
  updated_at     DateTime

  @@unique([post_id, quoted_post_id], name: "index_quoted_posts_on_post_id_and_quoted_post_id")
  @@unique([quoted_post_id, post_id], name: "index_quoted_posts_on_quoted_post_id_and_post_id")
}

model remote_themes {
  about_url         String?
  branch            String?
  commits_behind    Int?
  created_at        DateTime?
  id                Int       @default(autoincrement()) @id
  last_error_text   String?
  license_url       String?
  local_version     String?
  private_key       String?
  remote_updated_at DateTime?
  remote_url        String
  remote_version    String?
  updated_at        DateTime?
}

model scheduler_stats {
  duration_ms       Int?
  error             String?
  hostname          String
  id                Int      @default(autoincrement()) @id
  live_slots_finish Int?
  live_slots_start  Int?
  name              String
  pid               Int
  started_at        DateTime
  success           Boolean?
}

model schema_migration_details {
  created_at    DateTime
  direction     String?
  duration      Int?
  git_version   String?
  hostname      String?
  id            Int      @default(autoincrement()) @id
  name          String?
  rails_version String?
  version       String

  @@index([version], name: "index_schema_migration_details_on_version")
}

model schema_migrations {
  version String @unique
}

model screened_emails {
  action_type   Int
  created_at    DateTime
  email         String    @unique
  id            Int       @default(autoincrement()) @id
  ip_address    String?
  last_match_at DateTime?
  match_count   Int       @default(0)
  updated_at    DateTime

  @@index([last_match_at], name: "index_screened_emails_on_last_match_at")
}

model screened_ip_addresses {
  action_type   Int
  created_at    DateTime
  id            Int       @default(autoincrement()) @id
  ip_address    String    @unique
  last_match_at DateTime?
  match_count   Int       @default(0)
  updated_at    DateTime

  @@index([last_match_at], name: "index_screened_ip_addresses_on_last_match_at")
}

model screened_urls {
  action_type   Int
  created_at    DateTime
  domain        String
  id            Int       @default(autoincrement()) @id
  ip_address    String?
  last_match_at DateTime?
  match_count   Int       @default(0)
  updated_at    DateTime
  url           String    @unique

  @@index([last_match_at], name: "index_screened_urls_on_last_match_at")
}

model search_logs {
  created_at         DateTime
  id                 Int      @default(autoincrement()) @id
  ip_address         String?
  search_result_id   Int?
  search_result_type Int?
  search_type        Int
  term               String
  user_id            Int?
}

model shared_drafts {
  category_id Int
  created_at  DateTime
  id          Int      @default(autoincrement()) @id
  topic_id    Int      @unique
  updated_at  DateTime

  @@index([category_id], name: "index_shared_drafts_on_category_id")
}

model single_sign_on_records {
  created_at                      DateTime
  external_avatar_url             String?
  external_card_background_url    String?
  external_email                  String?
  external_id                     String   @unique
  external_name                   String?
  external_profile_background_url String?
  external_username               String?
  id                              Int      @default(autoincrement()) @id
  last_payload                    String
  updated_at                      DateTime
  user_id                         Int
}

model site_settings {
  created_at DateTime
  data_type  Int
  id         Int      @default(autoincrement()) @id
  name       String
  updated_at DateTime
  value      String?
}

model skipped_email_logs {
  created_at    DateTime
  custom_reason String?
  email_type    String
  id            Int      @default(autoincrement()) @id
  post_id       Int?
  reason_type   Int
  to_address    String
  updated_at    DateTime
  user_id       Int?

  @@index([created_at], name: "index_skipped_email_logs_on_created_at")
  @@index([post_id], name: "index_skipped_email_logs_on_post_id")
  @@index([reason_type], name: "index_skipped_email_logs_on_reason_type")
  @@index([user_id], name: "index_skipped_email_logs_on_user_id")
}

model stylesheet_cache {
  content    String
  created_at DateTime?
  digest     String
  id         Int       @default(autoincrement()) @id
  source_map String?
  target     String
  theme_id   Int
  updated_at DateTime?

  @@unique([target, digest], name: "index_stylesheet_cache_on_target_and_digest")
}

model tag_group_memberships {
  created_at   DateTime?
  id           Int       @default(autoincrement()) @id
  tag_group_id Int
  tag_id       Int
  updated_at   DateTime?

  @@unique([tag_group_id, tag_id], name: "index_tag_group_memberships_on_tag_group_id_and_tag_id")
}

model tag_group_permissions {
  created_at      DateTime
  group_id        Int
  id              Int      @default(autoincrement()) @id
  permission_type Int      @default(1)
  tag_group_id    Int
  updated_at      DateTime

  @@index([group_id], name: "index_tag_group_permissions_on_group_id")
  @@index([tag_group_id], name: "index_tag_group_permissions_on_tag_group_id")
}

model tag_groups {
  created_at    DateTime?
  id            Int       @default(autoincrement()) @id
  name          String
  one_per_topic Boolean?  @default(false)
  parent_tag_id Int?
  updated_at    DateTime?
}

model tags {
  created_at     DateTime?
  id             Int       @default(autoincrement()) @id
  name           String    @unique
  pm_topic_count Int       @default(0)
  topic_count    Int       @default(0)
  updated_at     DateTime?
}

model tag_search_data {
  locale      String?
  raw_data    String?
  search_data String?
  tag_id      Int     @default(autoincrement()) @id
  version     Int?    @default(0)

  @@index([search_data], name: "idx_search_tag")
}

model tag_users {
  created_at         DateTime?
  id                 Int       @default(autoincrement()) @id
  notification_level Int
  tag_id             Int
  updated_at         DateTime?
  user_id            Int

  @@unique([user_id, tag_id, notification_level], name: "idx_tag_users_ix1")
  @@unique([tag_id, user_id, notification_level], name: "idx_tag_users_ix2")
}

model theme_fields {
  compiler_version Int       @default(0)
  created_at       DateTime?
  error            String?
  id               Int       @default(autoincrement()) @id
  name             String
  target_id        Int
  theme_id         Int
  type_id          Int       @default(0)
  updated_at       DateTime?
  upload_id        Int?
  value            String
  value_baked      String?

  @@unique([theme_id, target_id, type_id, name], name: "theme_field_unique_index")
}

model themes {
  color_scheme_id  Int?
  compiler_version Int      @default(0)
  component        Boolean  @default(false)
  created_at       DateTime
  hidden           Boolean  @default(false)
  id               Int      @default(autoincrement()) @id
  name             String
  remote_theme_id  Int?     @unique
  updated_at       DateTime
  user_id          Int
  user_selectable  Boolean  @default(false)
}

model theme_settings {
  created_at DateTime
  data_type  Int
  id         Int      @default(autoincrement()) @id
  name       String
  theme_id   Int
  updated_at DateTime
  value      String?
}

model topic_allowed_groups {
  group_id Int
  id       Int @default(autoincrement()) @id
  topic_id Int

  @@unique([group_id, topic_id], name: "index_topic_allowed_groups_on_group_id_and_topic_id")
  @@unique([topic_id, group_id], name: "index_topic_allowed_groups_on_topic_id_and_group_id")
}

model topic_allowed_users {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  topic_id   Int
  updated_at DateTime
  user_id    Int

  @@unique([topic_id, user_id], name: "index_topic_allowed_users_on_topic_id_and_user_id")
  @@unique([user_id, topic_id], name: "index_topic_allowed_users_on_user_id_and_topic_id")
}

model topic_custom_fields {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  name       String
  topic_id   Int
  updated_at DateTime
  value      String?

  @@index([topic_id, name], name: "index_topic_custom_fields_on_topic_id_and_name")
  @@index([value, name], name: "topic_custom_fields_value_key_idx")
}

model topic_embeds {
  content_sha1  String?
  created_at    DateTime
  deleted_at    DateTime?
  deleted_by_id Int?
  embed_url     String    @unique
  id            Int       @default(autoincrement()) @id
  post_id       Int
  topic_id      Int
  updated_at    DateTime
}

model topic_invites {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  invite_id  Int
  topic_id   Int
  updated_at DateTime

  @@index([invite_id], name: "index_topic_invites_on_invite_id")
  @@unique([topic_id, invite_id], name: "index_topic_invites_on_topic_id_and_invite_id")
}

model topic_link_clicks {
  created_at    DateTime
  id            Int      @default(autoincrement()) @id
  ip_address    String?
  topic_link_id Int
  updated_at    DateTime
  user_id       Int?

  @@index([topic_link_id], name: "by_link")
}

model topic_links {
  clicks        Int       @default(0)
  crawled_at    DateTime?
  created_at    DateTime
  domain        String
  extension     String?
  id            Int       @default(autoincrement()) @id
  internal      Boolean   @default(false)
  link_post_id  Int?
  link_topic_id Int?
  post_id       Int?
  quote         Boolean   @default(false)
  reflection    Boolean?  @default(false)
  title         String?
  topic_id      Int
  updated_at    DateTime
  url           String
  user_id       Int

  @@index([extension], name: "index_topic_links_on_extension")
  @@index([link_post_id, reflection], name: "index_topic_links_on_link_post_id_and_reflection")
  @@index([post_id], name: "index_topic_links_on_post_id")
  @@index([topic_id], name: "index_topic_links_on_topic_id")
  @@unique([topic_id, post_id, url], name: "unique_post_links")
}

model topics {
  archetype                 String    @default("regular")
  archived                  Boolean   @default(false)
  avg_time                  Int?
  bumped_at                 DateTime
  category_id               Int?
  closed                    Boolean   @default(false)
  created_at                DateTime
  deleted_at                DateTime?
  deleted_by_id             Int?
  excerpt                   String?
  fancy_title               String?
  featured_link             String?
  featured_user1_id         Int?
  featured_user2_id         Int?
  featured_user3_id         Int?
  featured_user4_id         Int?
  has_summary               Boolean   @default(false)
  highest_post_number       Int       @default(0)
  highest_staff_post_number Int       @default(0)
  id                        Int       @default(autoincrement()) @id
  image_url                 String?
  incoming_link_count       Int       @default(0)
  last_posted_at            DateTime?
  last_post_user_id         Int
  like_count                Int       @default(0)
  moderator_posts_count     Int       @default(0)
  notify_moderators_count   Int       @default(0)
  participant_count         Int?      @default(1)
  percent_rank              Float     @default(1)
  pinned_at                 DateTime?
  pinned_globally           Boolean   @default(false)
  pinned_until              DateTime?
  posts_count               Int       @default(0)
  reply_count               Int       @default(0)
  score                     Float?
  slug                      String?
  spam_count                Int       @default(0)
  subtype                   String?
  title                     String
  updated_at                DateTime
  user_id                   Int?
  views                     Int       @default(0)
  visible                   Boolean   @default(true)
  word_count                Int?

  @@index([deleted_at, visible, archetype, category_id, id], name: "idx_topics_front_page")
  @@index([user_id], name: "idx_topics_user_id_deleted_at")
  @@index([slug], name: "idxtopicslug")
  @@index([bumped_at], name: "index_topics_on_bumped_at")
  @@index([created_at, visible], name: "index_topics_on_created_at_and_visible")
  @@index([id, deleted_at], name: "index_topics_on_id_and_deleted_at")
  @@index([pinned_at], name: "index_topics_on_pinned_at")
  @@index([pinned_globally], name: "index_topics_on_pinned_globally")
}

model topic_search_data {
  locale      String
  raw_data    String?
  search_data String?
  topic_id    Int     @id
  version     Int?    @default(0)

  @@index([search_data], name: "idx_search_topic")
}

model topic_tags {
  created_at DateTime?
  id         Int       @default(autoincrement()) @id
  tag_id     Int
  topic_id   Int
  updated_at DateTime?

  @@unique([topic_id, tag_id], name: "index_topic_tags_on_topic_id_and_tag_id")
}

model topic_timers {
  based_on_last_post Boolean   @default(false)
  category_id        Int?
  created_at         DateTime?
  deleted_at         DateTime?
  deleted_by_id      Int?
  execute_at         DateTime
  id                 Int       @default(autoincrement()) @id
  public_type        Boolean?  @default(true)
  status_type        Int
  topic_id           Int       @unique
  updated_at         DateTime?
  user_id            Int

  @@index([user_id], name: "index_topic_timers_on_user_id")
}

model topic_users {
  bookmarked               Boolean?  @default(false)
  cleared_pinned_at        DateTime?
  first_visited_at         DateTime?
  highest_seen_post_number Int?
  id                       Int       @default(autoincrement()) @id
  last_emailed_post_number Int?
  last_read_post_number    Int?
  last_visited_at          DateTime?
  liked                    Boolean?  @default(false)
  notification_level       Int       @default(1)
  notifications_changed_at DateTime?
  notifications_reason_id  Int?
  posted                   Boolean   @default(false)
  topic_id                 Int
  total_msecs_viewed       Int       @default(0)
  user_id                  Int

  @@unique([topic_id, user_id], name: "index_topic_users_on_topic_id_and_user_id")
  @@unique([user_id, topic_id], name: "index_topic_users_on_user_id_and_topic_id")
}

model topic_views {
  ip_address String?
  topic_id   Int
  user_id    Int?
  viewed_at  DateTime

  @@index([topic_id, viewed_at], name: "index_topic_views_on_topic_id_and_viewed_at")
  @@index([user_id, viewed_at], name: "index_topic_views_on_user_id_and_viewed_at")
  @@index([viewed_at, topic_id], name: "index_topic_views_on_viewed_at_and_topic_id")
  @@unique([user_id, ip_address, topic_id], name: "uniq_ip_or_user_id_topic_views")
}

model top_topics {
  all_score                Float? @default(0)
  daily_likes_count        Int    @default(0)
  daily_op_likes_count     Int    @default(0)
  daily_posts_count        Int    @default(0)
  daily_score              Float? @default(0)
  daily_views_count        Int    @default(0)
  id                       Int    @default(autoincrement()) @id
  monthly_likes_count      Int    @default(0)
  monthly_op_likes_count   Int    @default(0)
  monthly_posts_count      Int    @default(0)
  monthly_score            Float? @default(0)
  monthly_views_count      Int    @default(0)
  quarterly_likes_count    Int    @default(0)
  quarterly_op_likes_count Int    @default(0)
  quarterly_posts_count    Int    @default(0)
  quarterly_score          Float? @default(0)
  quarterly_views_count    Int    @default(0)
  topic_id                 Int?   @unique
  weekly_likes_count       Int    @default(0)
  weekly_op_likes_count    Int    @default(0)
  weekly_posts_count       Int    @default(0)
  weekly_score             Float? @default(0)
  weekly_views_count       Int    @default(0)
  yearly_likes_count       Int    @default(0)
  yearly_op_likes_count    Int    @default(0)
  yearly_posts_count       Int    @default(0)
  yearly_score             Float? @default(0)
  yearly_views_count       Int    @default(0)

  @@index([all_score], name: "index_top_topics_on_all_score")
  @@index([daily_likes_count], name: "index_top_topics_on_daily_likes_count")
  @@index([daily_op_likes_count], name: "index_top_topics_on_daily_op_likes_count")
  @@index([daily_posts_count], name: "index_top_topics_on_daily_posts_count")
  @@index([daily_score], name: "index_top_topics_on_daily_score")
  @@index([daily_views_count], name: "index_top_topics_on_daily_views_count")
  @@index([monthly_likes_count], name: "index_top_topics_on_monthly_likes_count")
  @@index([monthly_op_likes_count], name: "index_top_topics_on_monthly_op_likes_count")
  @@index([monthly_posts_count], name: "index_top_topics_on_monthly_posts_count")
  @@index([monthly_score], name: "index_top_topics_on_monthly_score")
  @@index([monthly_views_count], name: "index_top_topics_on_monthly_views_count")
  @@index([quarterly_likes_count], name: "index_top_topics_on_quarterly_likes_count")
  @@index([quarterly_op_likes_count], name: "index_top_topics_on_quarterly_op_likes_count")
  @@index([quarterly_posts_count], name: "index_top_topics_on_quarterly_posts_count")
  @@index([quarterly_views_count], name: "index_top_topics_on_quarterly_views_count")
  @@index([weekly_likes_count], name: "index_top_topics_on_weekly_likes_count")
  @@index([weekly_op_likes_count], name: "index_top_topics_on_weekly_op_likes_count")
  @@index([weekly_posts_count], name: "index_top_topics_on_weekly_posts_count")
  @@index([weekly_score], name: "index_top_topics_on_weekly_score")
  @@index([weekly_views_count], name: "index_top_topics_on_weekly_views_count")
  @@index([yearly_likes_count], name: "index_top_topics_on_yearly_likes_count")
  @@index([yearly_op_likes_count], name: "index_top_topics_on_yearly_op_likes_count")
  @@index([yearly_posts_count], name: "index_top_topics_on_yearly_posts_count")
  @@index([yearly_score], name: "index_top_topics_on_yearly_score")
  @@index([yearly_views_count], name: "index_top_topics_on_yearly_views_count")
}

model translation_overrides {
  compiled_js     String?
  created_at      DateTime
  id              Int      @default(autoincrement()) @id
  locale          String
  translation_key String
  updated_at      DateTime
  value           String

  @@unique([locale, translation_key], name: "index_translation_overrides_on_locale_and_translation_key")
}

model twitter_user_infos {
  created_at      DateTime
  email           String?
  id              Int      @default(autoincrement()) @id
  screen_name     String
  twitter_user_id Int      @unique
  updated_at      DateTime
  user_id         Int      @unique
}

model unsubscribe_keys {
  created_at           DateTime?
  key                  String    @id
  post_id              Int?
  topic_id             Int?
  unsubscribe_key_type String?
  updated_at           DateTime?
  user_id              Int

  @@index([created_at], name: "index_unsubscribe_keys_on_created_at")
}

model uploads {
  created_at        DateTime
  extension         String?
  filesize          Int
  height            Int?
  id                Int      @default(autoincrement()) @id
  origin            String?
  original_filename String
  retain_hours      Int?
  sha1              String?  @unique
  thumbnail_height  Int?
  thumbnail_width   Int?
  updated_at        DateTime
  url               String
  user_id           Int
  width             Int?

  @@index([id, url], name: "index_uploads_on_id_and_url")
  @@index([url], name: "index_uploads_on_url")
  @@index([user_id], name: "index_uploads_on_user_id")
}

model user_actions {
  acting_user_id  Int?
  action_type     Int
  created_at      DateTime
  id              Int      @default(autoincrement()) @id
  queued_post_id  Int?
  target_post_id  Int?
  target_topic_id Int?
  target_user_id  Int?
  updated_at      DateTime
  user_id         Int

  @@index([user_id, created_at, action_type], name: "idx_user_actions_speed_up_user_all")
  @@index([acting_user_id], name: "index_user_actions_on_acting_user_id")
  @@index([target_post_id], name: "index_user_actions_on_target_post_id")
  @@index([user_id, action_type], name: "index_user_actions_on_user_id_and_action_type")
  @@unique([action_type, user_id, target_topic_id, target_post_id, acting_user_id], name: "idx_unique_rows")
}

model user_api_keys {
  application_name String
  client_id        String    @unique
  created_at       DateTime?
  id               Int       @default(autoincrement()) @id
  key              String    @unique
  last_used_at     DateTime
  push_url         String?
  revoked_at       DateTime?
  scopes           String[]
  updated_at       DateTime?
  user_id          Int

  @@index([user_id], name: "index_user_api_keys_on_user_id")
}

model user_archived_messages {
  created_at DateTime?
  id         Int       @default(autoincrement()) @id
  topic_id   Int
  updated_at DateTime?
  user_id    Int

  @@unique([user_id, topic_id], name: "index_user_archived_messages_on_user_id_and_topic_id")
}

model user_auth_token_logs {
  action             String
  auth_token         String?
  client_ip          String?
  created_at         DateTime?
  id                 Int       @default(autoincrement()) @id
  path               String?
  user_agent         String?
  user_auth_token_id Int?
  user_id            Int?
}

model user_auth_tokens {
  auth_token      String    @unique
  auth_token_seen Boolean   @default(false)
  client_ip       String?
  created_at      DateTime?
  id              Int       @default(autoincrement()) @id
  prev_auth_token String    @unique
  rotated_at      DateTime
  seen_at         DateTime?
  updated_at      DateTime?
  user_agent      String?
  user_id         Int
}

model user_avatars {
  created_at                     DateTime
  custom_upload_id               Int?
  gravatar_upload_id             Int?
  id                             Int       @default(autoincrement()) @id
  last_gravatar_download_attempt DateTime?
  updated_at                     DateTime
  user_id                        Int

  @@index([custom_upload_id], name: "index_user_avatars_on_custom_upload_id")
  @@index([gravatar_upload_id], name: "index_user_avatars_on_gravatar_upload_id")
  @@index([user_id], name: "index_user_avatars_on_user_id")
}

model user_badges {
  badge_id        Int
  granted_at      DateTime
  granted_by_id   Int
  id              Int      @default(autoincrement()) @id
  notification_id Int?
  post_id         Int?
  seq             Int      @default(0)
  user_id         Int

  @@index([badge_id, user_id], name: "index_user_badges_on_badge_id_and_user_id")
  @@index([user_id], name: "index_user_badges_on_user_id")
  @@unique([badge_id, user_id, post_id], name: "index_user_badges_on_badge_id_and_user_id_and_post_id")
  @@unique([badge_id, user_id, seq], name: "index_user_badges_on_badge_id_and_user_id_and_seq")
}

model user_custom_fields {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  name       String
  updated_at DateTime
  user_id    Int
  value      String?

  @@index([user_id, name], name: "index_user_custom_fields_on_user_id_and_name")
}

model user_emails {
  created_at DateTime?
  email      String
  id         Int       @default(autoincrement()) @id
  primary    Boolean   @default(false)
  updated_at DateTime?
  user_id    Int

  @@index([user_id], name: "index_user_emails_on_user_id")
  @@unique([user_id, primary], name: "index_user_emails_on_user_id_and_primary")
}

model user_exports {
  created_at DateTime?
  file_name  String
  id         Int       @default(autoincrement()) @id
  updated_at DateTime?
  upload_id  Int?
  user_id    Int
}

model user_field_options {
  created_at    DateTime?
  id            Int       @default(autoincrement()) @id
  updated_at    DateTime?
  user_field_id Int
  value         String
}

model user_fields {
  created_at        DateTime?
  description       String
  editable          Boolean   @default(false)
  external_name     String?
  external_type     String?
  field_type        String
  id                Int       @default(autoincrement()) @id
  name              String
  position          Int?      @default(0)
  required          Boolean   @default(true)
  show_on_profile   Boolean   @default(false)
  show_on_user_card Boolean   @default(false)
  updated_at        DateTime?
}

model user_histories {
  acting_user_id Int?
  action         Int
  admin_only     Boolean? @default(false)
  category_id    Int?
  context        String?
  created_at     DateTime
  custom_type    String?
  details        String?
  email          String?
  id             Int      @default(autoincrement()) @id
  ip_address     String?
  new_value      String?
  post_id        Int?
  previous_value String?
  subject        String?
  target_user_id Int?
  topic_id       Int?
  updated_at     DateTime

  @@index([acting_user_id, action, id], name: "index_user_histories_on_acting_user_id_and_action_and_id")
  @@index([action, id], name: "index_user_histories_on_action_and_id")
  @@index([category_id], name: "index_user_histories_on_category_id")
  @@index([subject, id], name: "index_user_histories_on_subject_and_id")
  @@index([target_user_id, id], name: "index_user_histories_on_target_user_id_and_id")
}

model user_open_ids {
  active     Boolean
  created_at DateTime
  email      String
  id         Int      @default(autoincrement()) @id
  updated_at DateTime
  url        String
  user_id    Int

  @@index([url], name: "index_user_open_ids_on_url")
}

model user_options {
  allow_private_messages           Boolean   @default(true)
  automatically_unpin_topics       Boolean   @default(true)
  auto_track_topics_after_msecs    Int?
  digest_after_minutes             Int?
  disable_jump_reply               Boolean   @default(false)
  dynamic_favicon                  Boolean   @default(false)
  email_always                     Boolean   @default(false)
  email_digests                    Boolean?
  email_direct                     Boolean   @default(true)
  email_in_reply_to                Boolean   @default(true)
  email_previous_replies           Int       @default(2)
  email_private_messages           Boolean   @default(true)
  enable_quoting                   Boolean   @default(true)
  external_links_in_new_tab        Boolean   @default(false)
  hide_profile_and_presence        Boolean   @default(false)
  homepage_id                      Int?
  include_tl0_in_digests           Boolean?  @default(false)
  last_redirected_to_top_at        DateTime?
  like_notification_frequency      Int       @default(1)
  mailing_list_mode                Boolean   @default(false)
  mailing_list_mode_frequency      Int       @default(1)
  new_topic_duration_minutes       Int?
  notification_level_when_replying Int?
  theme_ids                        Int[]
  theme_key_seq                    Int       @default(0)
  user_id                          Int       @unique
}

model user_profiles {
  badge_granted_title  Boolean? @default(false)
  bio_cooked           String?
  bio_cooked_version   Int?
  bio_raw              String?
  card_background      String?
  dismissed_banner_key Int?
  location             String?
  profile_background   String?
  user_id              Int      @id
  views                Int      @default(0)
  website              String?

  @@index([bio_cooked_version], name: "index_user_profiles_on_bio_cooked_version")
  @@index([card_background], name: "index_user_profiles_on_card_background")
  @@index([profile_background], name: "index_user_profiles_on_profile_background")
}

model user_profile_views {
  id              Int      @default(autoincrement()) @id
  ip_address      String?
  user_id         Int?
  user_profile_id Int
  viewed_at       DateTime

  @@index([user_id], name: "index_user_profile_views_on_user_id")
  @@index([user_profile_id], name: "index_user_profile_views_on_user_profile_id")
  @@unique([viewed_at, user_id, ip_address, user_profile_id], name: "unique_profile_view_user_or_ip")
}

model users {
  active                    Boolean   @default(false)
  admin                     Boolean   @default(false)
  approved                  Boolean   @default(false)
  approved_at               DateTime?
  approved_by_id            Int?
  created_at                DateTime
  date_of_birth             DateTime?
  first_seen_at             DateTime?
  flag_level                Int       @default(0)
  group_locked_trust_level  Int?
  id                        Int       @default(autoincrement()) @id
  ip_address                String?
  last_emailed_at           DateTime?
  last_posted_at            DateTime?
  last_seen_at              DateTime?
  locale                    String?
  manual_locked_trust_level Int?
  moderator                 Boolean?  @default(false)
  name                      String?
  password_hash             String?
  previous_visit_at         DateTime?
  primary_group_id          Int?
  registration_ip_address   String?
  salt                      String?
  seen_notification_id      Int       @default(0)
  silenced_till             DateTime?
  staged                    Boolean   @default(false)
  suspended_at              DateTime?
  suspended_till            DateTime?
  title                     String?
  trust_level               Int
  updated_at                DateTime
  uploaded_avatar_id        Int?
  username                  String    @unique
  username_lower            String    @unique
  views                     Int       @default(0)

  @@index([id], name: "idx_users_admin")
  @@index([id], name: "idx_users_moderator")
  @@index([last_posted_at], name: "index_users_on_last_posted_at")
  @@index([last_seen_at], name: "index_users_on_last_seen_at")
  @@index([uploaded_avatar_id], name: "index_users_on_uploaded_avatar_id")
}

model user_search_data {
  locale      String?
  raw_data    String?
  search_data String?
  user_id     Int     @id
  version     Int?    @default(0)

  @@index([search_data], name: "idx_search_user")
}

model user_second_factors {
  created_at DateTime
  data       String
  enabled    Boolean   @default(false)
  id         Int       @default(autoincrement()) @id
  last_used  DateTime?
  method     Int
  updated_at DateTime
  user_id    Int

  @@index([user_id], name: "index_user_second_factors_on_user_id")
}

model user_stats {
  bounce_score             Float     @default(0)
  days_visited             Int       @default(0)
  first_post_created_at    DateTime?
  likes_given              Int       @default(0)
  likes_received           Int       @default(0)
  new_since                DateTime
  post_count               Int       @default(0)
  posts_read_count         Int       @default(0)
  read_faq                 DateTime?
  reset_bounce_score_after DateTime?
  time_read                Int       @default(0)
  topic_count              Int       @default(0)
  topic_reply_count        Int       @default(0)
  topics_entered           Int       @default(0)
  user_id                  Int       @id
}

model user_uploads {
  created_at DateTime
  id         Int      @default(autoincrement()) @id
  upload_id  Int
  user_id    Int

  @@unique([upload_id, user_id], name: "index_user_uploads_on_upload_id_and_user_id")
}

model user_visits {
  id         Int      @default(autoincrement()) @id
  mobile     Boolean? @default(false)
  posts_read Int?     @default(0)
  time_read  Int      @default(0)
  user_id    Int
  visited_at DateTime

  @@index([user_id, visited_at, time_read], name: "index_user_visits_on_user_id_and_visited_at_and_time_read")
  @@index([visited_at, mobile], name: "index_user_visits_on_visited_at_and_mobile")
  @@unique([user_id, visited_at], name: "index_user_visits_on_user_id_and_visited_at")
}

model user_warnings {
  created_at    DateTime?
  created_by_id Int
  id            Int       @default(autoincrement()) @id
  topic_id      Int       @unique
  updated_at    DateTime?
  user_id       Int

  @@index([user_id], name: "index_user_warnings_on_user_id")
}

model watched_words {
  action     Int
  created_at DateTime?
  id         Int       @default(autoincrement()) @id
  updated_at DateTime?
  word       String

  @@unique([action, word], name: "index_watched_words_on_action_and_word")
}

model web_crawler_requests {
  count      Int      @default(0)
  date       DateTime
  id         Int      @default(autoincrement()) @id
  user_agent String

  @@unique([date, user_agent], name: "index_web_crawler_requests_on_date_and_user_agent")
}

model web_hook_events {
  created_at       DateTime?
  duration         Int?      @default(0)
  headers          String?
  id               Int       @default(autoincrement()) @id
  payload          String?
  response_body    String?
  response_headers String?
  status           Int?      @default(0)
  updated_at       DateTime?
  web_hook_id      Int

  @@index([web_hook_id], name: "index_web_hook_events_on_web_hook_id")
}

model web_hook_event_types {
  id   Int    @default(autoincrement()) @id
  name String
}

model web_hook_event_types_hooks {
  web_hook_event_type_id Int
  web_hook_id            Int

  @@unique([web_hook_event_type_id, web_hook_id], name: "idx_web_hook_event_types_hooks_on_ids")
}

model web_hooks {
  active               Boolean   @default(false)
  content_type         Int       @default(1)
  created_at           DateTime?
  id                   Int       @default(autoincrement()) @id
  last_delivery_status Int       @default(1)
  payload_url          String
  secret               String?   @default("")
  status               Int       @default(1)
  updated_at           DateTime?
  verify_certificate   Boolean   @default(true)
  wildcard_web_hook    Boolean   @default(false)
}

Then you can successfully generate a Client that can be used with your script.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

4 participants