// This code was generated by `SqlHydra.Npgsql` -- v2.3.3.0.
namespace DataAccess


[<AutoOpen>]
module ColumnReaders =
    type Column(reader: System.Data.IDataReader, getOrdinal: string -> int, column) =
            member __.Name = column
            member __.IsNull() = getOrdinal column |> reader.IsDBNull
            override __.ToString() = __.Name

    type RequiredColumn<'T, 'Reader when 'Reader :> System.Data.IDataReader>(reader: 'Reader, getOrdinal, getter: int -> 'T, column) =
            inherit Column(reader, getOrdinal, column)
            member __.Read(?alias) = alias |> Option.defaultValue __.Name |> getOrdinal |> getter

    type OptionalColumn<'T, 'Reader when 'Reader :> System.Data.IDataReader>(reader: 'Reader, getOrdinal, getter: int -> 'T, column) =
            inherit Column(reader, getOrdinal, column)
            member __.Read(?alias) = 
                match alias |> Option.defaultValue __.Name |> getOrdinal with
                | o when reader.IsDBNull o -> None
                | o -> Some (getter o)

[<AutoOpen>]
module private DataReaderExtensions =
    type System.Data.IDataReader with
        member reader.GetDateOnly(ordinal: int) = 
            reader.GetDateTime(ordinal) |> System.DateOnly.FromDateTime
    
    type System.Data.Common.DbDataReader with
        member reader.GetTimeOnly(ordinal: int) = 
            reader.GetFieldValue(ordinal) |> System.TimeOnly.FromTimeSpan
        

module pgsodium =
    type key_status =
        | ``default`` = 1
        | valid = 2
        | invalid = 3
        | expired = 4

    type key_type =
        | ``aead-ietf`` = 1
        | ``aead-det`` = 2
        | hmacsha512 = 3
        | hmacsha256 = 4
        | auth = 5
        | shorthash = 6
        | generichash = 7
        | kdf = 8
        | secretbox = 9
        | secretstream = 10
        | stream_xchacha20 = 11

    [<CLIMutable>]
    type decrypted_key =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          expires: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Bigint")>]
          key_id: Option<int64>
          [<SqlHydra.ProviderDbType("Bytea")>]
          key_context: Option<byte []>
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          associated_data: Option<string>
          [<SqlHydra.ProviderDbType("Bytea")>]
          raw_key: Option<byte []>
          [<SqlHydra.ProviderDbType("Bytea")>]
          decrypted_raw_key: Option<byte []>
          [<SqlHydra.ProviderDbType("Bytea")>]
          raw_key_nonce: Option<byte []>
          [<SqlHydra.ProviderDbType("Uuid")>]
          parent_key: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          comment: Option<string>
          status: Option<key_status>
          key_type: Option<key_type> }

    let decrypted_key = SqlHydra.Query.Table.table<decrypted_key>

    [<CLIMutable>]
    type key =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created: System.DateTime
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          expires: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Bigint")>]
          key_id: Option<int64>
          [<SqlHydra.ProviderDbType("Bytea")>]
          key_context: Option<byte []>
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          associated_data: Option<string>
          [<SqlHydra.ProviderDbType("Bytea")>]
          raw_key: Option<byte []>
          [<SqlHydra.ProviderDbType("Bytea")>]
          raw_key_nonce: Option<byte []>
          [<SqlHydra.ProviderDbType("Uuid")>]
          parent_key: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          comment: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          user_data: Option<string>
          status: Option<key_status>
          key_type: Option<key_type> }

    let key = SqlHydra.Query.Table.table<key>

    [<CLIMutable>]
    type mask_columns =
        { [<SqlHydra.ProviderDbType("Name")>]
          attname: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          key_id: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          key_id_column: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          associated_columns: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          nonce_column: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          format_type: Option<string> }

    let mask_columns = SqlHydra.Query.Table.table<mask_columns>

    [<CLIMutable>]
    type masking_rule =
        { [<SqlHydra.ProviderDbType("Integer")>]
          attnum: Option<int>
          [<SqlHydra.ProviderDbType("Name")>]
          relname: Option<string>
          [<SqlHydra.ProviderDbType("Name")>]
          attname: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          format_type: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          col_description: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          key_id_column: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          key_id: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          associated_columns: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          nonce_column: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          view_name: Option<string>
          [<SqlHydra.ProviderDbType("Integer")>]
          priority: Option<int>
          [<SqlHydra.ProviderDbType("Boolean")>]
          security_invoker: Option<bool> }

    let masking_rule = SqlHydra.Query.Table.table<masking_rule>

    [<CLIMutable>]
    type valid_key =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Bigint")>]
          key_id: Option<int64>
          [<SqlHydra.ProviderDbType("Bytea")>]
          key_context: Option<byte []>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          expires: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          associated_data: Option<string>
          status: Option<key_status>
          key_type: Option<key_type> }

    let valid_key = SqlHydra.Query.Table.table<valid_key>

    module Readers =
        type decrypted_keyReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.created = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created")
            member __.expires = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "expires")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetInt64, "key_id")
            member __.key_context = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_context")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.associated_data = OptionalColumn(reader, getOrdinal, reader.GetString, "associated_data")
            member __.raw_key = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "raw_key")
            member __.decrypted_raw_key = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "decrypted_raw_key")
            member __.raw_key_nonce = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "raw_key_nonce")
            member __.parent_key = OptionalColumn(reader, getOrdinal, reader.GetGuid, "parent_key")
            member __.comment = OptionalColumn(reader, getOrdinal, reader.GetString, "comment")
            member __.status = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "status")
            member __.key_type = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_type")

            member __.Read() =
                { decrypted_key.id = __.id.Read()
                  created = __.created.Read()
                  expires = __.expires.Read()
                  key_id = __.key_id.Read()
                  key_context = __.key_context.Read()
                  name = __.name.Read()
                  associated_data = __.associated_data.Read()
                  raw_key = __.raw_key.Read()
                  decrypted_raw_key = __.decrypted_raw_key.Read()
                  raw_key_nonce = __.raw_key_nonce.Read()
                  parent_key = __.parent_key.Read()
                  comment = __.comment.Read()
                  status = __.status.Read()
                  key_type = __.key_type.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type keyReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.created = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "created")
            member __.expires = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "expires")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetInt64, "key_id")
            member __.key_context = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_context")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.associated_data = OptionalColumn(reader, getOrdinal, reader.GetString, "associated_data")
            member __.raw_key = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "raw_key")
            member __.raw_key_nonce = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "raw_key_nonce")
            member __.parent_key = OptionalColumn(reader, getOrdinal, reader.GetGuid, "parent_key")
            member __.comment = OptionalColumn(reader, getOrdinal, reader.GetString, "comment")
            member __.user_data = OptionalColumn(reader, getOrdinal, reader.GetString, "user_data")
            member __.status = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "status")
            member __.key_type = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_type")

            member __.Read() =
                { key.id = __.id.Read()
                  created = __.created.Read()
                  expires = __.expires.Read()
                  key_id = __.key_id.Read()
                  key_context = __.key_context.Read()
                  name = __.name.Read()
                  associated_data = __.associated_data.Read()
                  raw_key = __.raw_key.Read()
                  raw_key_nonce = __.raw_key_nonce.Read()
                  parent_key = __.parent_key.Read()
                  comment = __.comment.Read()
                  user_data = __.user_data.Read()
                  status = __.status.Read()
                  key_type = __.key_type.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type mask_columnsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.attname = OptionalColumn(reader, getOrdinal, reader.GetString, "attname")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetString, "key_id")
            member __.key_id_column = OptionalColumn(reader, getOrdinal, reader.GetString, "key_id_column")
            member __.associated_columns = OptionalColumn(reader, getOrdinal, reader.GetString, "associated_columns")
            member __.nonce_column = OptionalColumn(reader, getOrdinal, reader.GetString, "nonce_column")
            member __.format_type = OptionalColumn(reader, getOrdinal, reader.GetString, "format_type")

            member __.Read() =
                { mask_columns.attname = __.attname.Read()
                  key_id = __.key_id.Read()
                  key_id_column = __.key_id_column.Read()
                  associated_columns = __.associated_columns.Read()
                  nonce_column = __.nonce_column.Read()
                  format_type = __.format_type.Read() }

            member __.ReadIfNotNull() =
                if __.attname.IsNull() then None else Some(__.Read())

        type masking_ruleReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.attnum = OptionalColumn(reader, getOrdinal, reader.GetInt32, "attnum")
            member __.relname = OptionalColumn(reader, getOrdinal, reader.GetString, "relname")
            member __.attname = OptionalColumn(reader, getOrdinal, reader.GetString, "attname")
            member __.format_type = OptionalColumn(reader, getOrdinal, reader.GetString, "format_type")
            member __.col_description = OptionalColumn(reader, getOrdinal, reader.GetString, "col_description")
            member __.key_id_column = OptionalColumn(reader, getOrdinal, reader.GetString, "key_id_column")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetString, "key_id")
            member __.associated_columns = OptionalColumn(reader, getOrdinal, reader.GetString, "associated_columns")
            member __.nonce_column = OptionalColumn(reader, getOrdinal, reader.GetString, "nonce_column")
            member __.view_name = OptionalColumn(reader, getOrdinal, reader.GetString, "view_name")
            member __.priority = OptionalColumn(reader, getOrdinal, reader.GetInt32, "priority")
            member __.security_invoker = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "security_invoker")

            member __.Read() =
                { masking_rule.attnum = __.attnum.Read()
                  relname = __.relname.Read()
                  attname = __.attname.Read()
                  format_type = __.format_type.Read()
                  col_description = __.col_description.Read()
                  key_id_column = __.key_id_column.Read()
                  key_id = __.key_id.Read()
                  associated_columns = __.associated_columns.Read()
                  nonce_column = __.nonce_column.Read()
                  view_name = __.view_name.Read()
                  priority = __.priority.Read()
                  security_invoker = __.security_invoker.Read() }

            member __.ReadIfNotNull() =
                if __.attnum.IsNull() then None else Some(__.Read())

        type valid_keyReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetInt64, "key_id")
            member __.key_context = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_context")
            member __.created = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created")
            member __.expires = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "expires")
            member __.associated_data = OptionalColumn(reader, getOrdinal, reader.GetString, "associated_data")
            member __.status = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "status")
            member __.key_type = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "key_type")

            member __.Read() =
                { valid_key.id = __.id.Read()
                  name = __.name.Read()
                  key_id = __.key_id.Read()
                  key_context = __.key_context.Read()
                  created = __.created.Read()
                  expires = __.expires.Read()
                  associated_data = __.associated_data.Read()
                  status = __.status.Read()
                  key_type = __.key_type.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

module auth =
    type aal_level =
        | aal1 = 1
        | aal2 = 2
        | aal3 = 3

    type code_challenge_method =
        | s256 = 1
        | plain = 2

    type factor_status =
        | unverified = 1
        | verified = 2

    type factor_type =
        | totp = 1
        | webauthn = 2

    [<CLIMutable>]
    type audit_log_entries =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          instance_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Json")>]
          payload: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          ip_address: string }

    let audit_log_entries = SqlHydra.Query.Table.table<audit_log_entries>

    [<CLIMutable>]
    type flow_state =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          user_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          auth_code: string
          [<SqlHydra.ProviderDbType("Text")>]
          code_challenge: string
          [<SqlHydra.ProviderDbType("Text")>]
          provider_type: string
          [<SqlHydra.ProviderDbType("Text")>]
          provider_access_token: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          provider_refresh_token: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          authentication_method: string
          code_challenge_method: code_challenge_method }

    let flow_state = SqlHydra.Query.Table.table<flow_state>

    [<CLIMutable>]
    type identities =
        { [<SqlHydra.ProviderDbType("Text")>]
          provider_id: string
          [<SqlHydra.ProviderDbType("Uuid")>]
          user_id: System.Guid
          [<SqlHydra.ProviderDbType("Jsonb")>]
          identity_data: string
          [<SqlHydra.ProviderDbType("Text")>]
          provider: string
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          last_sign_in_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          email: Option<string>
          [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid }

    let identities = SqlHydra.Query.Table.table<identities>

    [<CLIMutable>]
    type instances =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          uuid: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          raw_base_config: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime> }

    let instances = SqlHydra.Query.Table.table<instances>

    [<CLIMutable>]
    type mfa_amr_claims =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          session_id: System.Guid
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: System.DateTime
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: System.DateTime
          [<SqlHydra.ProviderDbType("Text")>]
          authentication_method: string
          [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid }

    let mfa_amr_claims = SqlHydra.Query.Table.table<mfa_amr_claims>

    [<CLIMutable>]
    type mfa_challenges =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          factor_id: System.Guid
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: System.DateTime
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          verified_at: Option<System.DateTime> }

    let mfa_challenges = SqlHydra.Query.Table.table<mfa_challenges>

    [<CLIMutable>]
    type mfa_factors =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          user_id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          friendly_name: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: System.DateTime
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: System.DateTime
          [<SqlHydra.ProviderDbType("Text")>]
          secret: Option<string>
          factor_type: factor_type
          status: factor_status }

    let mfa_factors = SqlHydra.Query.Table.table<mfa_factors>

    [<CLIMutable>]
    type refresh_tokens =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          instance_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Bigint")>]
          id: int64
          [<SqlHydra.ProviderDbType("Varchar")>]
          token: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          user_id: Option<string>
          [<SqlHydra.ProviderDbType("Boolean")>]
          revoked: Option<bool>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          parent: Option<string>
          [<SqlHydra.ProviderDbType("Uuid")>]
          session_id: Option<System.Guid> }

    let refresh_tokens = SqlHydra.Query.Table.table<refresh_tokens>

    [<CLIMutable>]
    type saml_providers =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          sso_provider_id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          entity_id: string
          [<SqlHydra.ProviderDbType("Text")>]
          metadata_xml: string
          [<SqlHydra.ProviderDbType("Text")>]
          metadata_url: Option<string>
          [<SqlHydra.ProviderDbType("Jsonb")>]
          attribute_mapping: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime> }

    let saml_providers = SqlHydra.Query.Table.table<saml_providers>

    [<CLIMutable>]
    type saml_relay_states =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          sso_provider_id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          request_id: string
          [<SqlHydra.ProviderDbType("Text")>]
          for_email: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          redirect_to: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Uuid")>]
          flow_state_id: Option<System.Guid> }

    let saml_relay_states = SqlHydra.Query.Table.table<saml_relay_states>

    [<CLIMutable>]
    type schema_migrations =
        { [<SqlHydra.ProviderDbType("Varchar")>]
          version: string }

    let schema_migrations = SqlHydra.Query.Table.table<schema_migrations>

    [<CLIMutable>]
    type sessions =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          user_id: System.Guid
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Uuid")>]
          factor_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          not_after: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          refreshed_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          user_agent: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          tag: Option<string>
          aal: Option<aal_level> }

    let sessions = SqlHydra.Query.Table.table<sessions>

    [<CLIMutable>]
    type sso_domains =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Uuid")>]
          sso_provider_id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          domain: string
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime> }

    let sso_domains = SqlHydra.Query.Table.table<sso_domains>

    [<CLIMutable>]
    type sso_providers =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          resource_id: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime> }

    let sso_providers = SqlHydra.Query.Table.table<sso_providers>

    [<CLIMutable>]
    type users =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          instance_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Varchar")>]
          aud: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          role: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          email: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          encrypted_password: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          email_confirmed_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          invited_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          confirmation_token: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          confirmation_sent_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          recovery_token: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          recovery_sent_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          email_change_token_new: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          email_change: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          email_change_sent_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          last_sign_in_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Jsonb")>]
          raw_app_meta_data: Option<string>
          [<SqlHydra.ProviderDbType("Jsonb")>]
          raw_user_meta_data: Option<string>
          [<SqlHydra.ProviderDbType("Boolean")>]
          is_super_admin: Option<bool>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          phone: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          phone_confirmed_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Text")>]
          phone_change: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          phone_change_token: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          phone_change_sent_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          confirmed_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          email_change_token_current: Option<string>
          [<SqlHydra.ProviderDbType("Smallint")>]
          email_change_confirm_status: Option<int16>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          banned_until: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          reauthentication_token: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          reauthentication_sent_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Boolean")>]
          is_sso_user: bool
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          deleted_at: Option<System.DateTime> }

    let users = SqlHydra.Query.Table.table<users>

    module Readers =
        type audit_log_entriesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.instance_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "instance_id")
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.payload = OptionalColumn(reader, getOrdinal, reader.GetString, "payload")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.ip_address = RequiredColumn(reader, getOrdinal, reader.GetString, "ip_address")

            member __.Read() =
                { audit_log_entries.instance_id = __.instance_id.Read()
                  id = __.id.Read()
                  payload = __.payload.Read()
                  created_at = __.created_at.Read()
                  ip_address = __.ip_address.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type flow_stateReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.user_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "user_id")
            member __.auth_code = RequiredColumn(reader, getOrdinal, reader.GetString, "auth_code")
            member __.code_challenge = RequiredColumn(reader, getOrdinal, reader.GetString, "code_challenge")
            member __.provider_type = RequiredColumn(reader, getOrdinal, reader.GetString, "provider_type")
            member __.provider_access_token = OptionalColumn(reader, getOrdinal, reader.GetString, "provider_access_token")
            member __.provider_refresh_token = OptionalColumn(reader, getOrdinal, reader.GetString, "provider_refresh_token")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.authentication_method = RequiredColumn(reader, getOrdinal, reader.GetString, "authentication_method")
            member __.code_challenge_method = RequiredColumn(reader, getOrdinal, reader.GetFieldValue, "code_challenge_method")

            member __.Read() =
                { flow_state.id = __.id.Read()
                  user_id = __.user_id.Read()
                  auth_code = __.auth_code.Read()
                  code_challenge = __.code_challenge.Read()
                  provider_type = __.provider_type.Read()
                  provider_access_token = __.provider_access_token.Read()
                  provider_refresh_token = __.provider_refresh_token.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  authentication_method = __.authentication_method.Read()
                  code_challenge_method = __.code_challenge_method.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type identitiesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.provider_id = RequiredColumn(reader, getOrdinal, reader.GetString, "provider_id")
            member __.user_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "user_id")
            member __.identity_data = RequiredColumn(reader, getOrdinal, reader.GetString, "identity_data")
            member __.provider = RequiredColumn(reader, getOrdinal, reader.GetString, "provider")
            member __.last_sign_in_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "last_sign_in_at")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.email = OptionalColumn(reader, getOrdinal, reader.GetString, "email")
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")

            member __.Read() =
                { identities.provider_id = __.provider_id.Read()
                  user_id = __.user_id.Read()
                  identity_data = __.identity_data.Read()
                  provider = __.provider.Read()
                  last_sign_in_at = __.last_sign_in_at.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  email = __.email.Read()
                  id = __.id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type instancesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.uuid = OptionalColumn(reader, getOrdinal, reader.GetGuid, "uuid")
            member __.raw_base_config = OptionalColumn(reader, getOrdinal, reader.GetString, "raw_base_config")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { instances.id = __.id.Read()
                  uuid = __.uuid.Read()
                  raw_base_config = __.raw_base_config.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type mfa_amr_claimsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.session_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "session_id")
            member __.created_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.authentication_method = RequiredColumn(reader, getOrdinal, reader.GetString, "authentication_method")
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")

            member __.Read() =
                { mfa_amr_claims.session_id = __.session_id.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  authentication_method = __.authentication_method.Read()
                  id = __.id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type mfa_challengesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.factor_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "factor_id")
            member __.created_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.verified_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "verified_at")

            member __.Read() =
                { mfa_challenges.id = __.id.Read()
                  factor_id = __.factor_id.Read()
                  created_at = __.created_at.Read()
                  verified_at = __.verified_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type mfa_factorsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.user_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "user_id")
            member __.friendly_name = OptionalColumn(reader, getOrdinal, reader.GetString, "friendly_name")
            member __.created_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.secret = OptionalColumn(reader, getOrdinal, reader.GetString, "secret")
            member __.factor_type = RequiredColumn(reader, getOrdinal, reader.GetFieldValue, "factor_type")
            member __.status = RequiredColumn(reader, getOrdinal, reader.GetFieldValue, "status")

            member __.Read() =
                { mfa_factors.id = __.id.Read()
                  user_id = __.user_id.Read()
                  friendly_name = __.friendly_name.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  secret = __.secret.Read()
                  factor_type = __.factor_type.Read()
                  status = __.status.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type refresh_tokensReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.instance_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "instance_id")
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt64, "id")
            member __.token = OptionalColumn(reader, getOrdinal, reader.GetString, "token")
            member __.user_id = OptionalColumn(reader, getOrdinal, reader.GetString, "user_id")
            member __.revoked = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "revoked")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.parent = OptionalColumn(reader, getOrdinal, reader.GetString, "parent")
            member __.session_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "session_id")

            member __.Read() =
                { refresh_tokens.instance_id = __.instance_id.Read()
                  id = __.id.Read()
                  token = __.token.Read()
                  user_id = __.user_id.Read()
                  revoked = __.revoked.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  parent = __.parent.Read()
                  session_id = __.session_id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type saml_providersReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.sso_provider_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "sso_provider_id")
            member __.entity_id = RequiredColumn(reader, getOrdinal, reader.GetString, "entity_id")
            member __.metadata_xml = RequiredColumn(reader, getOrdinal, reader.GetString, "metadata_xml")
            member __.metadata_url = OptionalColumn(reader, getOrdinal, reader.GetString, "metadata_url")
            member __.attribute_mapping = OptionalColumn(reader, getOrdinal, reader.GetString, "attribute_mapping")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { saml_providers.id = __.id.Read()
                  sso_provider_id = __.sso_provider_id.Read()
                  entity_id = __.entity_id.Read()
                  metadata_xml = __.metadata_xml.Read()
                  metadata_url = __.metadata_url.Read()
                  attribute_mapping = __.attribute_mapping.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type saml_relay_statesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.sso_provider_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "sso_provider_id")
            member __.request_id = RequiredColumn(reader, getOrdinal, reader.GetString, "request_id")
            member __.for_email = OptionalColumn(reader, getOrdinal, reader.GetString, "for_email")
            member __.redirect_to = OptionalColumn(reader, getOrdinal, reader.GetString, "redirect_to")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.flow_state_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "flow_state_id")

            member __.Read() =
                { saml_relay_states.id = __.id.Read()
                  sso_provider_id = __.sso_provider_id.Read()
                  request_id = __.request_id.Read()
                  for_email = __.for_email.Read()
                  redirect_to = __.redirect_to.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  flow_state_id = __.flow_state_id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type schema_migrationsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.version = RequiredColumn(reader, getOrdinal, reader.GetString, "version")

            member __.Read() =
                { schema_migrations.version = __.version.Read() }

            member __.ReadIfNotNull() =
                if __.version.IsNull() then None else Some(__.Read())

        type sessionsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.user_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "user_id")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.factor_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "factor_id")
            member __.not_after = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "not_after")
            member __.refreshed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "refreshed_at")
            member __.user_agent = OptionalColumn(reader, getOrdinal, reader.GetString, "user_agent")
            member __.tag = OptionalColumn(reader, getOrdinal, reader.GetString, "tag")
            member __.aal = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "aal")

            member __.Read() =
                { sessions.id = __.id.Read()
                  user_id = __.user_id.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  factor_id = __.factor_id.Read()
                  not_after = __.not_after.Read()
                  refreshed_at = __.refreshed_at.Read()
                  user_agent = __.user_agent.Read()
                  tag = __.tag.Read()
                  aal = __.aal.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type sso_domainsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.sso_provider_id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "sso_provider_id")
            member __.domain = RequiredColumn(reader, getOrdinal, reader.GetString, "domain")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { sso_domains.id = __.id.Read()
                  sso_provider_id = __.sso_provider_id.Read()
                  domain = __.domain.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type sso_providersReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.resource_id = OptionalColumn(reader, getOrdinal, reader.GetString, "resource_id")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { sso_providers.id = __.id.Read()
                  resource_id = __.resource_id.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type usersReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.instance_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "instance_id")
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.aud = OptionalColumn(reader, getOrdinal, reader.GetString, "aud")
            member __.role = OptionalColumn(reader, getOrdinal, reader.GetString, "role")
            member __.email = OptionalColumn(reader, getOrdinal, reader.GetString, "email")
            member __.encrypted_password = OptionalColumn(reader, getOrdinal, reader.GetString, "encrypted_password")
            member __.email_confirmed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "email_confirmed_at")
            member __.invited_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "invited_at")
            member __.confirmation_token = OptionalColumn(reader, getOrdinal, reader.GetString, "confirmation_token")
            member __.confirmation_sent_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "confirmation_sent_at")
            member __.recovery_token = OptionalColumn(reader, getOrdinal, reader.GetString, "recovery_token")
            member __.recovery_sent_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "recovery_sent_at")
            member __.email_change_token_new = OptionalColumn(reader, getOrdinal, reader.GetString, "email_change_token_new")
            member __.email_change = OptionalColumn(reader, getOrdinal, reader.GetString, "email_change")
            member __.email_change_sent_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "email_change_sent_at")
            member __.last_sign_in_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "last_sign_in_at")
            member __.raw_app_meta_data = OptionalColumn(reader, getOrdinal, reader.GetString, "raw_app_meta_data")
            member __.raw_user_meta_data = OptionalColumn(reader, getOrdinal, reader.GetString, "raw_user_meta_data")
            member __.is_super_admin = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "is_super_admin")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.phone = OptionalColumn(reader, getOrdinal, reader.GetString, "phone")
            member __.phone_confirmed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "phone_confirmed_at")
            member __.phone_change = OptionalColumn(reader, getOrdinal, reader.GetString, "phone_change")
            member __.phone_change_token = OptionalColumn(reader, getOrdinal, reader.GetString, "phone_change_token")
            member __.phone_change_sent_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "phone_change_sent_at")
            member __.confirmed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "confirmed_at")
            member __.email_change_token_current = OptionalColumn(reader, getOrdinal, reader.GetString, "email_change_token_current")
            member __.email_change_confirm_status = OptionalColumn(reader, getOrdinal, reader.GetInt16, "email_change_confirm_status")
            member __.banned_until = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "banned_until")
            member __.reauthentication_token = OptionalColumn(reader, getOrdinal, reader.GetString, "reauthentication_token")
            member __.reauthentication_sent_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "reauthentication_sent_at")
            member __.is_sso_user = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "is_sso_user")
            member __.deleted_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "deleted_at")

            member __.Read() =
                { users.instance_id = __.instance_id.Read()
                  id = __.id.Read()
                  aud = __.aud.Read()
                  role = __.role.Read()
                  email = __.email.Read()
                  encrypted_password = __.encrypted_password.Read()
                  email_confirmed_at = __.email_confirmed_at.Read()
                  invited_at = __.invited_at.Read()
                  confirmation_token = __.confirmation_token.Read()
                  confirmation_sent_at = __.confirmation_sent_at.Read()
                  recovery_token = __.recovery_token.Read()
                  recovery_sent_at = __.recovery_sent_at.Read()
                  email_change_token_new = __.email_change_token_new.Read()
                  email_change = __.email_change.Read()
                  email_change_sent_at = __.email_change_sent_at.Read()
                  last_sign_in_at = __.last_sign_in_at.Read()
                  raw_app_meta_data = __.raw_app_meta_data.Read()
                  raw_user_meta_data = __.raw_user_meta_data.Read()
                  is_super_admin = __.is_super_admin.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  phone = __.phone.Read()
                  phone_confirmed_at = __.phone_confirmed_at.Read()
                  phone_change = __.phone_change.Read()
                  phone_change_token = __.phone_change_token.Read()
                  phone_change_sent_at = __.phone_change_sent_at.Read()
                  confirmed_at = __.confirmed_at.Read()
                  email_change_token_current = __.email_change_token_current.Read()
                  email_change_confirm_status = __.email_change_confirm_status.Read()
                  banned_until = __.banned_until.Read()
                  reauthentication_token = __.reauthentication_token.Read()
                  reauthentication_sent_at = __.reauthentication_sent_at.Read()
                  is_sso_user = __.is_sso_user.Read()
                  deleted_at = __.deleted_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

module cron =
    [<CLIMutable>]
    type job =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          jobid: int64
          [<SqlHydra.ProviderDbType("Text")>]
          schedule: string
          [<SqlHydra.ProviderDbType("Text")>]
          command: string
          [<SqlHydra.ProviderDbType("Text")>]
          nodename: string
          [<SqlHydra.ProviderDbType("Integer")>]
          nodeport: int
          [<SqlHydra.ProviderDbType("Text")>]
          database: string
          [<SqlHydra.ProviderDbType("Text")>]
          username: string
          [<SqlHydra.ProviderDbType("Boolean")>]
          active: bool
          [<SqlHydra.ProviderDbType("Name")>]
          jobname: Option<string> }

    let job = SqlHydra.Query.Table.table<job>

    [<CLIMutable>]
    type job_run_details =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          jobid: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          runid: int64
          [<SqlHydra.ProviderDbType("Integer")>]
          job_pid: Option<int>
          [<SqlHydra.ProviderDbType("Text")>]
          database: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          username: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          command: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          status: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          return_message: Option<string>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          start_time: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          end_time: Option<System.DateTime> }

    let job_run_details = SqlHydra.Query.Table.table<job_run_details>

    module Readers =
        type jobReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.jobid = RequiredColumn(reader, getOrdinal, reader.GetInt64, "jobid")
            member __.schedule = RequiredColumn(reader, getOrdinal, reader.GetString, "schedule")
            member __.command = RequiredColumn(reader, getOrdinal, reader.GetString, "command")
            member __.nodename = RequiredColumn(reader, getOrdinal, reader.GetString, "nodename")
            member __.nodeport = RequiredColumn(reader, getOrdinal, reader.GetInt32, "nodeport")
            member __.database = RequiredColumn(reader, getOrdinal, reader.GetString, "database")
            member __.username = RequiredColumn(reader, getOrdinal, reader.GetString, "username")
            member __.active = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "active")
            member __.jobname = OptionalColumn(reader, getOrdinal, reader.GetString, "jobname")

            member __.Read() =
                { job.jobid = __.jobid.Read()
                  schedule = __.schedule.Read()
                  command = __.command.Read()
                  nodename = __.nodename.Read()
                  nodeport = __.nodeport.Read()
                  database = __.database.Read()
                  username = __.username.Read()
                  active = __.active.Read()
                  jobname = __.jobname.Read() }

            member __.ReadIfNotNull() =
                if __.jobid.IsNull() then None else Some(__.Read())

        type job_run_detailsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.jobid = OptionalColumn(reader, getOrdinal, reader.GetInt64, "jobid")
            member __.runid = RequiredColumn(reader, getOrdinal, reader.GetInt64, "runid")
            member __.job_pid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "job_pid")
            member __.database = OptionalColumn(reader, getOrdinal, reader.GetString, "database")
            member __.username = OptionalColumn(reader, getOrdinal, reader.GetString, "username")
            member __.command = OptionalColumn(reader, getOrdinal, reader.GetString, "command")
            member __.status = OptionalColumn(reader, getOrdinal, reader.GetString, "status")
            member __.return_message = OptionalColumn(reader, getOrdinal, reader.GetString, "return_message")
            member __.start_time = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "start_time")
            member __.end_time = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "end_time")

            member __.Read() =
                { job_run_details.jobid = __.jobid.Read()
                  runid = __.runid.Read()
                  job_pid = __.job_pid.Read()
                  database = __.database.Read()
                  username = __.username.Read()
                  command = __.command.Read()
                  status = __.status.Read()
                  return_message = __.return_message.Read()
                  start_time = __.start_time.Read()
                  end_time = __.end_time.Read() }

            member __.ReadIfNotNull() =
                if __.runid.IsNull() then None else Some(__.Read())

module extensions =
    [<CLIMutable>]
    type pg_stat_statements =
        { [<SqlHydra.ProviderDbType("Boolean")>]
          toplevel: Option<bool>
          [<SqlHydra.ProviderDbType("Bigint")>]
          queryid: Option<int64>
          [<SqlHydra.ProviderDbType("Text")>]
          query: Option<string>
          [<SqlHydra.ProviderDbType("Bigint")>]
          plans: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          total_plan_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          min_plan_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          max_plan_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          mean_plan_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          stddev_plan_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          calls: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          total_exec_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          min_exec_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          max_exec_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          mean_exec_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          stddev_exec_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          rows: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          shared_blks_hit: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          shared_blks_read: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          shared_blks_dirtied: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          shared_blks_written: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          local_blks_hit: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          local_blks_read: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          local_blks_dirtied: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          local_blks_written: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          temp_blks_read: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          temp_blks_written: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          blk_read_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          blk_write_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          temp_blk_read_time: Option<double>
          [<SqlHydra.ProviderDbType("Double")>]
          temp_blk_write_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          wal_records: Option<int64>
          [<SqlHydra.ProviderDbType("Bigint")>]
          wal_fpi: Option<int64>
          [<SqlHydra.ProviderDbType("Numeric")>]
          wal_bytes: Option<decimal>
          [<SqlHydra.ProviderDbType("Bigint")>]
          jit_functions: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          jit_generation_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          jit_inlining_count: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          jit_inlining_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          jit_optimization_count: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          jit_optimization_time: Option<double>
          [<SqlHydra.ProviderDbType("Bigint")>]
          jit_emission_count: Option<int64>
          [<SqlHydra.ProviderDbType("Double")>]
          jit_emission_time: Option<double> }

    let pg_stat_statements = SqlHydra.Query.Table.table<pg_stat_statements>

    [<CLIMutable>]
    type pg_stat_statements_info =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          dealloc: Option<int64>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          stats_reset: Option<System.DateTime> }

    let pg_stat_statements_info = SqlHydra.Query.Table.table<pg_stat_statements_info>

    module Readers =
        type pg_stat_statementsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.toplevel = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "toplevel")
            member __.queryid = OptionalColumn(reader, getOrdinal, reader.GetInt64, "queryid")
            member __.query = OptionalColumn(reader, getOrdinal, reader.GetString, "query")
            member __.plans = OptionalColumn(reader, getOrdinal, reader.GetInt64, "plans")
            member __.total_plan_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "total_plan_time")
            member __.min_plan_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "min_plan_time")
            member __.max_plan_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "max_plan_time")
            member __.mean_plan_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "mean_plan_time")
            member __.stddev_plan_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "stddev_plan_time")
            member __.calls = OptionalColumn(reader, getOrdinal, reader.GetInt64, "calls")
            member __.total_exec_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "total_exec_time")
            member __.min_exec_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "min_exec_time")
            member __.max_exec_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "max_exec_time")
            member __.mean_exec_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "mean_exec_time")
            member __.stddev_exec_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "stddev_exec_time")
            member __.rows = OptionalColumn(reader, getOrdinal, reader.GetInt64, "rows")
            member __.shared_blks_hit = OptionalColumn(reader, getOrdinal, reader.GetInt64, "shared_blks_hit")
            member __.shared_blks_read = OptionalColumn(reader, getOrdinal, reader.GetInt64, "shared_blks_read")
            member __.shared_blks_dirtied = OptionalColumn(reader, getOrdinal, reader.GetInt64, "shared_blks_dirtied")
            member __.shared_blks_written = OptionalColumn(reader, getOrdinal, reader.GetInt64, "shared_blks_written")
            member __.local_blks_hit = OptionalColumn(reader, getOrdinal, reader.GetInt64, "local_blks_hit")
            member __.local_blks_read = OptionalColumn(reader, getOrdinal, reader.GetInt64, "local_blks_read")
            member __.local_blks_dirtied = OptionalColumn(reader, getOrdinal, reader.GetInt64, "local_blks_dirtied")
            member __.local_blks_written = OptionalColumn(reader, getOrdinal, reader.GetInt64, "local_blks_written")
            member __.temp_blks_read = OptionalColumn(reader, getOrdinal, reader.GetInt64, "temp_blks_read")
            member __.temp_blks_written = OptionalColumn(reader, getOrdinal, reader.GetInt64, "temp_blks_written")
            member __.blk_read_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "blk_read_time")
            member __.blk_write_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "blk_write_time")
            member __.temp_blk_read_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "temp_blk_read_time")
            member __.temp_blk_write_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "temp_blk_write_time")
            member __.wal_records = OptionalColumn(reader, getOrdinal, reader.GetInt64, "wal_records")
            member __.wal_fpi = OptionalColumn(reader, getOrdinal, reader.GetInt64, "wal_fpi")
            member __.wal_bytes = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "wal_bytes")
            member __.jit_functions = OptionalColumn(reader, getOrdinal, reader.GetInt64, "jit_functions")
            member __.jit_generation_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "jit_generation_time")
            member __.jit_inlining_count = OptionalColumn(reader, getOrdinal, reader.GetInt64, "jit_inlining_count")
            member __.jit_inlining_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "jit_inlining_time")
            member __.jit_optimization_count = OptionalColumn(reader, getOrdinal, reader.GetInt64, "jit_optimization_count")
            member __.jit_optimization_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "jit_optimization_time")
            member __.jit_emission_count = OptionalColumn(reader, getOrdinal, reader.GetInt64, "jit_emission_count")
            member __.jit_emission_time = OptionalColumn(reader, getOrdinal, reader.GetDouble, "jit_emission_time")

            member __.Read() =
                { pg_stat_statements.toplevel = __.toplevel.Read()
                  queryid = __.queryid.Read()
                  query = __.query.Read()
                  plans = __.plans.Read()
                  total_plan_time = __.total_plan_time.Read()
                  min_plan_time = __.min_plan_time.Read()
                  max_plan_time = __.max_plan_time.Read()
                  mean_plan_time = __.mean_plan_time.Read()
                  stddev_plan_time = __.stddev_plan_time.Read()
                  calls = __.calls.Read()
                  total_exec_time = __.total_exec_time.Read()
                  min_exec_time = __.min_exec_time.Read()
                  max_exec_time = __.max_exec_time.Read()
                  mean_exec_time = __.mean_exec_time.Read()
                  stddev_exec_time = __.stddev_exec_time.Read()
                  rows = __.rows.Read()
                  shared_blks_hit = __.shared_blks_hit.Read()
                  shared_blks_read = __.shared_blks_read.Read()
                  shared_blks_dirtied = __.shared_blks_dirtied.Read()
                  shared_blks_written = __.shared_blks_written.Read()
                  local_blks_hit = __.local_blks_hit.Read()
                  local_blks_read = __.local_blks_read.Read()
                  local_blks_dirtied = __.local_blks_dirtied.Read()
                  local_blks_written = __.local_blks_written.Read()
                  temp_blks_read = __.temp_blks_read.Read()
                  temp_blks_written = __.temp_blks_written.Read()
                  blk_read_time = __.blk_read_time.Read()
                  blk_write_time = __.blk_write_time.Read()
                  temp_blk_read_time = __.temp_blk_read_time.Read()
                  temp_blk_write_time = __.temp_blk_write_time.Read()
                  wal_records = __.wal_records.Read()
                  wal_fpi = __.wal_fpi.Read()
                  wal_bytes = __.wal_bytes.Read()
                  jit_functions = __.jit_functions.Read()
                  jit_generation_time = __.jit_generation_time.Read()
                  jit_inlining_count = __.jit_inlining_count.Read()
                  jit_inlining_time = __.jit_inlining_time.Read()
                  jit_optimization_count = __.jit_optimization_count.Read()
                  jit_optimization_time = __.jit_optimization_time.Read()
                  jit_emission_count = __.jit_emission_count.Read()
                  jit_emission_time = __.jit_emission_time.Read() }

            member __.ReadIfNotNull() =
                if __.toplevel.IsNull() then None else Some(__.Read())

        type pg_stat_statements_infoReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.dealloc = OptionalColumn(reader, getOrdinal, reader.GetInt64, "dealloc")
            member __.stats_reset = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "stats_reset")

            member __.Read() =
                { pg_stat_statements_info.dealloc = __.dealloc.Read()
                  stats_reset = __.stats_reset.Read() }

            member __.ReadIfNotNull() =
                if __.dealloc.IsNull() then None else Some(__.Read())

module grate =
    [<CLIMutable>]
    type ScriptsRun =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          id: int64
          [<SqlHydra.ProviderDbType("Bigint")>]
          version_id: Option<int64>
          [<SqlHydra.ProviderDbType("Varchar")>]
          script_name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          text_of_script: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          text_hash: Option<string>
          [<SqlHydra.ProviderDbType("Boolean")>]
          one_time_script: Option<bool>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          entry_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          modified_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          entered_by: Option<string> }

    let ScriptsRun = SqlHydra.Query.Table.table<ScriptsRun>

    [<CLIMutable>]
    type ScriptsRunErrors =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          id: int64
          [<SqlHydra.ProviderDbType("Varchar")>]
          repository_path: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          version: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          script_name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          text_of_script: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          erroneous_part_of_script: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          error_message: Option<string>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          entry_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          modified_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          entered_by: Option<string> }

    let ScriptsRunErrors = SqlHydra.Query.Table.table<ScriptsRunErrors>

    [<CLIMutable>]
    type Version =
        { [<SqlHydra.ProviderDbType("Bigint")>]
          id: int64
          [<SqlHydra.ProviderDbType("Varchar")>]
          repository_path: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          version: Option<string>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          entry_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Timestamp")>]
          modified_date: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Varchar")>]
          entered_by: Option<string>
          [<SqlHydra.ProviderDbType("Varchar")>]
          status: Option<string> }

    let Version = SqlHydra.Query.Table.table<Version>

    module Readers =
        type ScriptsRunReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt64, "id")
            member __.version_id = OptionalColumn(reader, getOrdinal, reader.GetInt64, "version_id")
            member __.script_name = OptionalColumn(reader, getOrdinal, reader.GetString, "script_name")
            member __.text_of_script = OptionalColumn(reader, getOrdinal, reader.GetString, "text_of_script")
            member __.text_hash = OptionalColumn(reader, getOrdinal, reader.GetString, "text_hash")
            member __.one_time_script = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "one_time_script")
            member __.entry_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "entry_date")
            member __.modified_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "modified_date")
            member __.entered_by = OptionalColumn(reader, getOrdinal, reader.GetString, "entered_by")

            member __.Read() =
                { ScriptsRun.id = __.id.Read()
                  version_id = __.version_id.Read()
                  script_name = __.script_name.Read()
                  text_of_script = __.text_of_script.Read()
                  text_hash = __.text_hash.Read()
                  one_time_script = __.one_time_script.Read()
                  entry_date = __.entry_date.Read()
                  modified_date = __.modified_date.Read()
                  entered_by = __.entered_by.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type ScriptsRunErrorsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt64, "id")
            member __.repository_path = OptionalColumn(reader, getOrdinal, reader.GetString, "repository_path")
            member __.version = OptionalColumn(reader, getOrdinal, reader.GetString, "version")
            member __.script_name = OptionalColumn(reader, getOrdinal, reader.GetString, "script_name")
            member __.text_of_script = OptionalColumn(reader, getOrdinal, reader.GetString, "text_of_script")
            member __.erroneous_part_of_script = OptionalColumn(reader, getOrdinal, reader.GetString, "erroneous_part_of_script")
            member __.error_message = OptionalColumn(reader, getOrdinal, reader.GetString, "error_message")
            member __.entry_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "entry_date")
            member __.modified_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "modified_date")
            member __.entered_by = OptionalColumn(reader, getOrdinal, reader.GetString, "entered_by")

            member __.Read() =
                { ScriptsRunErrors.id = __.id.Read()
                  repository_path = __.repository_path.Read()
                  version = __.version.Read()
                  script_name = __.script_name.Read()
                  text_of_script = __.text_of_script.Read()
                  erroneous_part_of_script = __.erroneous_part_of_script.Read()
                  error_message = __.error_message.Read()
                  entry_date = __.entry_date.Read()
                  modified_date = __.modified_date.Read()
                  entered_by = __.entered_by.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type VersionReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt64, "id")
            member __.repository_path = OptionalColumn(reader, getOrdinal, reader.GetString, "repository_path")
            member __.version = OptionalColumn(reader, getOrdinal, reader.GetString, "version")
            member __.entry_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "entry_date")
            member __.modified_date = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "modified_date")
            member __.entered_by = OptionalColumn(reader, getOrdinal, reader.GetString, "entered_by")
            member __.status = OptionalColumn(reader, getOrdinal, reader.GetString, "status")

            member __.Read() =
                { Version.id = __.id.Read()
                  repository_path = __.repository_path.Read()
                  version = __.version.Read()
                  entry_date = __.entry_date.Read()
                  modified_date = __.modified_date.Read()
                  entered_by = __.entered_by.Read()
                  status = __.status.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

module ``public`` =
    [<CLIMutable>]
    type article_tags =
        { [<SqlHydra.ProviderDbType("Integer")>]
          articleid: int
          [<SqlHydra.ProviderDbType("Integer")>]
          tagid: int }

    let article_tags = SqlHydra.Query.Table.table<article_tags>

    [<CLIMutable>]
    type articles =
        { [<SqlHydra.ProviderDbType("Integer")>]
          id: int
          [<SqlHydra.ProviderDbType("Text")>]
          title: string
          [<SqlHydra.ProviderDbType("Text")>]
          source: string
          [<SqlHydra.ProviderDbType("Text")>]
          parsed: string
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          createdon: System.DateTime
          [<SqlHydra.ProviderDbType("Text")>]
          description: string }

    let articles = SqlHydra.Query.Table.table<articles>

    [<CLIMutable>]
    type tags =
        { [<SqlHydra.ProviderDbType("Integer")>]
          id: int
          [<SqlHydra.ProviderDbType("Text")>]
          name: string }

    let tags = SqlHydra.Query.Table.table<tags>

    module Readers =
        type article_tagsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.articleid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "articleid")
            member __.tagid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "tagid")

            member __.Read() =
                { article_tags.articleid = __.articleid.Read()
                  tagid = __.tagid.Read() }

            member __.ReadIfNotNull() =
                if __.articleid.IsNull() then None else Some(__.Read())

        type articlesReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt32, "id")
            member __.title = RequiredColumn(reader, getOrdinal, reader.GetString, "title")
            member __.source = RequiredColumn(reader, getOrdinal, reader.GetString, "source")
            member __.parsed = RequiredColumn(reader, getOrdinal, reader.GetString, "parsed")
            member __.createdon = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "createdon")
            member __.description = RequiredColumn(reader, getOrdinal, reader.GetString, "description")

            member __.Read() =
                { articles.id = __.id.Read()
                  title = __.title.Read()
                  source = __.source.Read()
                  parsed = __.parsed.Read()
                  createdon = __.createdon.Read()
                  description = __.description.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type tagsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt32, "id")
            member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name")

            member __.Read() =
                { tags.id = __.id.Read()
                  name = __.name.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

module storage =
    [<CLIMutable>]
    type buckets =
        { [<SqlHydra.ProviderDbType("Text")>]
          id: string
          [<SqlHydra.ProviderDbType("Text")>]
          name: string
          [<SqlHydra.ProviderDbType("Uuid")>]
          owner: Option<System.Guid>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Boolean")>]
          ``public``: Option<bool>
          [<SqlHydra.ProviderDbType("Boolean")>]
          avif_autodetection: Option<bool>
          [<SqlHydra.ProviderDbType("Bigint")>]
          file_size_limit: Option<int64>
          [<SqlHydra.ProviderDbType("Text,Array")>]
          allowed_mime_types: Option<string []>
          [<SqlHydra.ProviderDbType("Text")>]
          owner_id: Option<string> }

    let buckets = SqlHydra.Query.Table.table<buckets>

    [<CLIMutable>]
    type migrations =
        { [<SqlHydra.ProviderDbType("Integer")>]
          id: int
          [<SqlHydra.ProviderDbType("Varchar")>]
          name: string
          [<SqlHydra.ProviderDbType("Varchar")>]
          hash: string
          [<SqlHydra.ProviderDbType("Timestamp")>]
          executed_at: Option<System.DateTime> }

    let migrations = SqlHydra.Query.Table.table<migrations>

    [<CLIMutable>]
    type objects =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          bucket_id: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Uuid")>]
          owner: Option<System.Guid>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          last_accessed_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("Jsonb")>]
          metadata: Option<string>
          [<SqlHydra.ProviderDbType("Text,Array")>]
          path_tokens: Option<string []>
          [<SqlHydra.ProviderDbType("Text")>]
          version: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          owner_id: Option<string> }

    let objects = SqlHydra.Query.Table.table<objects>

    module Readers =
        type bucketsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetString, "id")
            member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name")
            member __.owner = OptionalColumn(reader, getOrdinal, reader.GetGuid, "owner")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.``public`` = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "public")
            member __.avif_autodetection = OptionalColumn(reader, getOrdinal, reader.GetBoolean, "avif_autodetection")
            member __.file_size_limit = OptionalColumn(reader, getOrdinal, reader.GetInt64, "file_size_limit")
            member __.allowed_mime_types = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "allowed_mime_types")
            member __.owner_id = OptionalColumn(reader, getOrdinal, reader.GetString, "owner_id")

            member __.Read() =
                { buckets.id = __.id.Read()
                  name = __.name.Read()
                  owner = __.owner.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  ``public`` = __.``public``.Read()
                  avif_autodetection = __.avif_autodetection.Read()
                  file_size_limit = __.file_size_limit.Read()
                  allowed_mime_types = __.allowed_mime_types.Read()
                  owner_id = __.owner_id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type migrationsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt32, "id")
            member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name")
            member __.hash = RequiredColumn(reader, getOrdinal, reader.GetString, "hash")
            member __.executed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "executed_at")

            member __.Read() =
                { migrations.id = __.id.Read()
                  name = __.name.Read()
                  hash = __.hash.Read()
                  executed_at = __.executed_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type objectsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.bucket_id = OptionalColumn(reader, getOrdinal, reader.GetString, "bucket_id")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.owner = OptionalColumn(reader, getOrdinal, reader.GetGuid, "owner")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")
            member __.last_accessed_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "last_accessed_at")
            member __.metadata = OptionalColumn(reader, getOrdinal, reader.GetString, "metadata")
            member __.path_tokens = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "path_tokens")
            member __.version = OptionalColumn(reader, getOrdinal, reader.GetString, "version")
            member __.owner_id = OptionalColumn(reader, getOrdinal, reader.GetString, "owner_id")

            member __.Read() =
                { objects.id = __.id.Read()
                  bucket_id = __.bucket_id.Read()
                  name = __.name.Read()
                  owner = __.owner.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read()
                  last_accessed_at = __.last_accessed_at.Read()
                  metadata = __.metadata.Read()
                  path_tokens = __.path_tokens.Read()
                  version = __.version.Read()
                  owner_id = __.owner_id.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

module vault =
    [<CLIMutable>]
    type decrypted_secrets =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          description: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          secret: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          decrypted_secret: Option<string>
          [<SqlHydra.ProviderDbType("Uuid")>]
          key_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Bytea")>]
          nonce: Option<byte []>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: Option<System.DateTime>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: Option<System.DateTime> }

    let decrypted_secrets = SqlHydra.Query.Table.table<decrypted_secrets>

    [<CLIMutable>]
    type secrets =
        { [<SqlHydra.ProviderDbType("Uuid")>]
          id: System.Guid
          [<SqlHydra.ProviderDbType("Text")>]
          name: Option<string>
          [<SqlHydra.ProviderDbType("Text")>]
          description: string
          [<SqlHydra.ProviderDbType("Text")>]
          secret: string
          [<SqlHydra.ProviderDbType("Uuid")>]
          key_id: Option<System.Guid>
          [<SqlHydra.ProviderDbType("Bytea")>]
          nonce: Option<byte []>
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          created_at: System.DateTime
          [<SqlHydra.ProviderDbType("TimestampTz")>]
          updated_at: System.DateTime }

    let secrets = SqlHydra.Query.Table.table<secrets>

    module Readers =
        type decrypted_secretsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.description = OptionalColumn(reader, getOrdinal, reader.GetString, "description")
            member __.secret = OptionalColumn(reader, getOrdinal, reader.GetString, "secret")
            member __.decrypted_secret = OptionalColumn(reader, getOrdinal, reader.GetString, "decrypted_secret")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "key_id")
            member __.nonce = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "nonce")
            member __.created_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { decrypted_secrets.id = __.id.Read()
                  name = __.name.Read()
                  description = __.description.Read()
                  secret = __.secret.Read()
                  decrypted_secret = __.decrypted_secret.Read()
                  key_id = __.key_id.Read()
                  nonce = __.nonce.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

        type secretsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) =
            member __.id = RequiredColumn(reader, getOrdinal, reader.GetGuid, "id")
            member __.name = OptionalColumn(reader, getOrdinal, reader.GetString, "name")
            member __.description = RequiredColumn(reader, getOrdinal, reader.GetString, "description")
            member __.secret = RequiredColumn(reader, getOrdinal, reader.GetString, "secret")
            member __.key_id = OptionalColumn(reader, getOrdinal, reader.GetGuid, "key_id")
            member __.nonce = OptionalColumn(reader, getOrdinal, reader.GetFieldValue, "nonce")
            member __.created_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "created_at")
            member __.updated_at = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "updated_at")

            member __.Read() =
                { secrets.id = __.id.Read()
                  name = __.name.Read()
                  description = __.description.Read()
                  secret = __.secret.Read()
                  key_id = __.key_id.Read()
                  nonce = __.nonce.Read()
                  created_at = __.created_at.Read()
                  updated_at = __.updated_at.Read() }

            member __.ReadIfNotNull() =
                if __.id.IsNull() then None else Some(__.Read())

type HydraReader(reader: Npgsql.NpgsqlDataReader) =
    let mutable accFieldCount = 0
    let buildGetOrdinal fieldCount =
        let dictionary = 
            [0..reader.FieldCount-1] 
            |> List.map (fun i -> reader.GetName(i), i)
            |> List.sortBy snd
            |> List.skip accFieldCount
            |> List.take fieldCount
            |> dict
        accFieldCount <- accFieldCount + fieldCount
        fun col -> dictionary.Item col
        
    let lazypgsodiumdecrypted_key = lazy (pgsodium.Readers.decrypted_keyReader (reader, buildGetOrdinal 14))
    let lazypgsodiumkey = lazy (pgsodium.Readers.keyReader (reader, buildGetOrdinal 14))
    let lazypgsodiummask_columns = lazy (pgsodium.Readers.mask_columnsReader (reader, buildGetOrdinal 7))
    let lazypgsodiummasking_rule = lazy (pgsodium.Readers.masking_ruleReader (reader, buildGetOrdinal 14))
    let lazypgsodiumvalid_key = lazy (pgsodium.Readers.valid_keyReader (reader, buildGetOrdinal 9))
    let lazyauthaudit_log_entries = lazy (auth.Readers.audit_log_entriesReader (reader, buildGetOrdinal 5))
    let lazyauthflow_state = lazy (auth.Readers.flow_stateReader (reader, buildGetOrdinal 11))
    let lazyauthidentities = lazy (auth.Readers.identitiesReader (reader, buildGetOrdinal 9))
    let lazyauthinstances = lazy (auth.Readers.instancesReader (reader, buildGetOrdinal 5))
    let lazyauthmfa_amr_claims = lazy (auth.Readers.mfa_amr_claimsReader (reader, buildGetOrdinal 5))
    let lazyauthmfa_challenges = lazy (auth.Readers.mfa_challengesReader (reader, buildGetOrdinal 5))
    let lazyauthmfa_factors = lazy (auth.Readers.mfa_factorsReader (reader, buildGetOrdinal 8))
    let lazyauthrefresh_tokens = lazy (auth.Readers.refresh_tokensReader (reader, buildGetOrdinal 9))
    let lazyauthsaml_providers = lazy (auth.Readers.saml_providersReader (reader, buildGetOrdinal 8))
    let lazyauthsaml_relay_states = lazy (auth.Readers.saml_relay_statesReader (reader, buildGetOrdinal 9))
    let lazyauthschema_migrations = lazy (auth.Readers.schema_migrationsReader (reader, buildGetOrdinal 1))
    let lazyauthsessions = lazy (auth.Readers.sessionsReader (reader, buildGetOrdinal 11))
    let lazyauthsso_domains = lazy (auth.Readers.sso_domainsReader (reader, buildGetOrdinal 5))
    let lazyauthsso_providers = lazy (auth.Readers.sso_providersReader (reader, buildGetOrdinal 4))
    let lazyauthusers = lazy (auth.Readers.usersReader (reader, buildGetOrdinal 34))
    let lazycronjob = lazy (cron.Readers.jobReader (reader, buildGetOrdinal 9))
    let lazycronjob_run_details = lazy (cron.Readers.job_run_detailsReader (reader, buildGetOrdinal 10))
    let lazyextensionspg_stat_statements = lazy (extensions.Readers.pg_stat_statementsReader (reader, buildGetOrdinal 43))
    let lazyextensionspg_stat_statements_info = lazy (extensions.Readers.pg_stat_statements_infoReader (reader, buildGetOrdinal 2))
    let lazygrateScriptsRun = lazy (grate.Readers.ScriptsRunReader(reader, buildGetOrdinal 9))
    let lazygrateScriptsRunErrors = lazy (grate.Readers.ScriptsRunErrorsReader(reader, buildGetOrdinal 10))
    let lazygrateVersion = lazy (grate.Readers.VersionReader(reader, buildGetOrdinal 7))
    let lazypublicarticle_tags = lazy (``public``.Readers.article_tagsReader (reader, buildGetOrdinal 2))
    let lazypublicarticles = lazy (``public``.Readers.articlesReader (reader, buildGetOrdinal 6))
    let lazypublictags = lazy (``public``.Readers.tagsReader (reader, buildGetOrdinal 2))
    let lazystoragebuckets = lazy (storage.Readers.bucketsReader (reader, buildGetOrdinal 10))
    let lazystoragemigrations = lazy (storage.Readers.migrationsReader (reader, buildGetOrdinal 4))
    let lazystorageobjects = lazy (storage.Readers.objectsReader (reader, buildGetOrdinal 11))
    let lazyvaultdecrypted_secrets = lazy (vault.Readers.decrypted_secretsReader (reader, buildGetOrdinal 9))
    let lazyvaultsecrets = lazy (vault.Readers.secretsReader (reader, buildGetOrdinal 8))
    member __.``pgsodium.decrypted_key`` = lazypgsodiumdecrypted_key.Value
    member __.``pgsodium.key`` = lazypgsodiumkey.Value
    member __.``pgsodium.mask_columns`` = lazypgsodiummask_columns.Value
    member __.``pgsodium.masking_rule`` = lazypgsodiummasking_rule.Value
    member __.``pgsodium.valid_key`` = lazypgsodiumvalid_key.Value
    member __.``auth.audit_log_entries`` = lazyauthaudit_log_entries.Value
    member __.``auth.flow_state`` = lazyauthflow_state.Value
    member __.``auth.identities`` = lazyauthidentities.Value
    member __.``auth.instances`` = lazyauthinstances.Value
    member __.``auth.mfa_amr_claims`` = lazyauthmfa_amr_claims.Value
    member __.``auth.mfa_challenges`` = lazyauthmfa_challenges.Value
    member __.``auth.mfa_factors`` = lazyauthmfa_factors.Value
    member __.``auth.refresh_tokens`` = lazyauthrefresh_tokens.Value
    member __.``auth.saml_providers`` = lazyauthsaml_providers.Value
    member __.``auth.saml_relay_states`` = lazyauthsaml_relay_states.Value
    member __.``auth.schema_migrations`` = lazyauthschema_migrations.Value
    member __.``auth.sessions`` = lazyauthsessions.Value
    member __.``auth.sso_domains`` = lazyauthsso_domains.Value
    member __.``auth.sso_providers`` = lazyauthsso_providers.Value
    member __.``auth.users`` = lazyauthusers.Value
    member __.``cron.job`` = lazycronjob.Value
    member __.``cron.job_run_details`` = lazycronjob_run_details.Value
    member __.``extensions.pg_stat_statements`` = lazyextensionspg_stat_statements.Value
    member __.``extensions.pg_stat_statements_info`` = lazyextensionspg_stat_statements_info.Value
    member __.``grate.ScriptsRun`` = lazygrateScriptsRun.Value
    member __.``grate.ScriptsRunErrors`` = lazygrateScriptsRunErrors.Value
    member __.``grate.Version`` = lazygrateVersion.Value
    member __.``public.article_tags`` = lazypublicarticle_tags.Value
    member __.``public.articles`` = lazypublicarticles.Value
    member __.``public.tags`` = lazypublictags.Value
    member __.``storage.buckets`` = lazystoragebuckets.Value
    member __.``storage.migrations`` = lazystoragemigrations.Value
    member __.``storage.objects`` = lazystorageobjects.Value
    member __.``vault.decrypted_secrets`` = lazyvaultdecrypted_secrets.Value
    member __.``vault.secrets`` = lazyvaultsecrets.Value
    member private __.AccFieldCount with get () = accFieldCount and set (value) = accFieldCount <- value

    member private __.GetReaderByName(entity: string, isOption: bool) =
        match entity, isOption with
        | "pgsodium.decrypted_key", false -> __.``pgsodium.decrypted_key``.Read >> box
        | "pgsodium.decrypted_key", true -> __.``pgsodium.decrypted_key``.ReadIfNotNull >> box
        | "pgsodium.key", false -> __.``pgsodium.key``.Read >> box
        | "pgsodium.key", true -> __.``pgsodium.key``.ReadIfNotNull >> box
        | "pgsodium.mask_columns", false -> __.``pgsodium.mask_columns``.Read >> box
        | "pgsodium.mask_columns", true -> __.``pgsodium.mask_columns``.ReadIfNotNull >> box
        | "pgsodium.masking_rule", false -> __.``pgsodium.masking_rule``.Read >> box
        | "pgsodium.masking_rule", true -> __.``pgsodium.masking_rule``.ReadIfNotNull >> box
        | "pgsodium.valid_key", false -> __.``pgsodium.valid_key``.Read >> box
        | "pgsodium.valid_key", true -> __.``pgsodium.valid_key``.ReadIfNotNull >> box
        | "auth.audit_log_entries", false -> __.``auth.audit_log_entries``.Read >> box
        | "auth.audit_log_entries", true -> __.``auth.audit_log_entries``.ReadIfNotNull >> box
        | "auth.flow_state", false -> __.``auth.flow_state``.Read >> box
        | "auth.flow_state", true -> __.``auth.flow_state``.ReadIfNotNull >> box
        | "auth.identities", false -> __.``auth.identities``.Read >> box
        | "auth.identities", true -> __.``auth.identities``.ReadIfNotNull >> box
        | "auth.instances", false -> __.``auth.instances``.Read >> box
        | "auth.instances", true -> __.``auth.instances``.ReadIfNotNull >> box
        | "auth.mfa_amr_claims", false -> __.``auth.mfa_amr_claims``.Read >> box
        | "auth.mfa_amr_claims", true -> __.``auth.mfa_amr_claims``.ReadIfNotNull >> box
        | "auth.mfa_challenges", false -> __.``auth.mfa_challenges``.Read >> box
        | "auth.mfa_challenges", true -> __.``auth.mfa_challenges``.ReadIfNotNull >> box
        | "auth.mfa_factors", false -> __.``auth.mfa_factors``.Read >> box
        | "auth.mfa_factors", true -> __.``auth.mfa_factors``.ReadIfNotNull >> box
        | "auth.refresh_tokens", false -> __.``auth.refresh_tokens``.Read >> box
        | "auth.refresh_tokens", true -> __.``auth.refresh_tokens``.ReadIfNotNull >> box
        | "auth.saml_providers", false -> __.``auth.saml_providers``.Read >> box
        | "auth.saml_providers", true -> __.``auth.saml_providers``.ReadIfNotNull >> box
        | "auth.saml_relay_states", false -> __.``auth.saml_relay_states``.Read >> box
        | "auth.saml_relay_states", true -> __.``auth.saml_relay_states``.ReadIfNotNull >> box
        | "auth.schema_migrations", false -> __.``auth.schema_migrations``.Read >> box
        | "auth.schema_migrations", true -> __.``auth.schema_migrations``.ReadIfNotNull >> box
        | "auth.sessions", false -> __.``auth.sessions``.Read >> box
        | "auth.sessions", true -> __.``auth.sessions``.ReadIfNotNull >> box
        | "auth.sso_domains", false -> __.``auth.sso_domains``.Read >> box
        | "auth.sso_domains", true -> __.``auth.sso_domains``.ReadIfNotNull >> box
        | "auth.sso_providers", false -> __.``auth.sso_providers``.Read >> box
        | "auth.sso_providers", true -> __.``auth.sso_providers``.ReadIfNotNull >> box
        | "auth.users", false -> __.``auth.users``.Read >> box
        | "auth.users", true -> __.``auth.users``.ReadIfNotNull >> box
        | "cron.job", false -> __.``cron.job``.Read >> box
        | "cron.job", true -> __.``cron.job``.ReadIfNotNull >> box
        | "cron.job_run_details", false -> __.``cron.job_run_details``.Read >> box
        | "cron.job_run_details", true -> __.``cron.job_run_details``.ReadIfNotNull >> box
        | "extensions.pg_stat_statements", false -> __.``extensions.pg_stat_statements``.Read >> box
        | "extensions.pg_stat_statements", true -> __.``extensions.pg_stat_statements``.ReadIfNotNull >> box
        | "extensions.pg_stat_statements_info", false -> __.``extensions.pg_stat_statements_info``.Read >> box
        | "extensions.pg_stat_statements_info", true -> __.``extensions.pg_stat_statements_info``.ReadIfNotNull >> box
        | "grate.ScriptsRun", false -> __.``grate.ScriptsRun``.Read >> box
        | "grate.ScriptsRun", true -> __.``grate.ScriptsRun``.ReadIfNotNull >> box
        | "grate.ScriptsRunErrors", false -> __.``grate.ScriptsRunErrors``.Read >> box
        | "grate.ScriptsRunErrors", true -> __.``grate.ScriptsRunErrors``.ReadIfNotNull >> box
        | "grate.Version", false -> __.``grate.Version``.Read >> box
        | "grate.Version", true -> __.``grate.Version``.ReadIfNotNull >> box
        | "public.article_tags", false -> __.``public.article_tags``.Read >> box
        | "public.article_tags", true -> __.``public.article_tags``.ReadIfNotNull >> box
        | "public.articles", false -> __.``public.articles``.Read >> box
        | "public.articles", true -> __.``public.articles``.ReadIfNotNull >> box
        | "public.tags", false -> __.``public.tags``.Read >> box
        | "public.tags", true -> __.``public.tags``.ReadIfNotNull >> box
        | "storage.buckets", false -> __.``storage.buckets``.Read >> box
        | "storage.buckets", true -> __.``storage.buckets``.ReadIfNotNull >> box
        | "storage.migrations", false -> __.``storage.migrations``.Read >> box
        | "storage.migrations", true -> __.``storage.migrations``.ReadIfNotNull >> box
        | "storage.objects", false -> __.``storage.objects``.Read >> box
        | "storage.objects", true -> __.``storage.objects``.ReadIfNotNull >> box
        | "vault.decrypted_secrets", false -> __.``vault.decrypted_secrets``.Read >> box
        | "vault.decrypted_secrets", true -> __.``vault.decrypted_secrets``.ReadIfNotNull >> box
        | "vault.secrets", false -> __.``vault.secrets``.Read >> box
        | "vault.secrets", true -> __.``vault.secrets``.ReadIfNotNull >> box
        | _ -> failwith $"Could not read type '{entity}' because no generated reader exists."

    static member private GetPrimitiveReader(t: System.Type, reader: Npgsql.NpgsqlDataReader, isOpt: bool) =
        let wrap get (ord: int) = 
            if isOpt 
            then (if reader.IsDBNull ord then None else get ord |> Some) |> box 
            else get ord |> box 
        

        if t = typedefof<bool> then Some(wrap reader.GetBoolean)
        else if t = typedefof<bool []> then Some(wrap reader.GetFieldValue<bool []>)
        else if t = typedefof<int16> then Some(wrap reader.GetInt16)
        else if t = typedefof<int16 []> then Some(wrap reader.GetFieldValue<int16 []>)
        else if t = typedefof<int> then Some(wrap reader.GetInt32)
        else if t = typedefof<int []> then Some(wrap reader.GetFieldValue<int []>)
        else if t = typedefof<int64> then Some(wrap reader.GetInt64)
        else if t = typedefof<int64 []> then Some(wrap reader.GetFieldValue<int64 []>)
        else if t = typedefof<double> then Some(wrap reader.GetDouble)
        else if t = typedefof<double []> then Some(wrap reader.GetFieldValue<double []>)
        else if t = typedefof<decimal> then Some(wrap reader.GetDecimal)
        else if t = typedefof<decimal []> then Some(wrap reader.GetFieldValue<decimal []>)
        else if t = typedefof<string> then Some(wrap reader.GetString)
        else if t = typedefof<string []> then Some(wrap reader.GetFieldValue<string []>)
        else if t = typedefof<System.Guid> then Some(wrap reader.GetGuid)
        else if t = typedefof<System.Guid []> then Some(wrap reader.GetFieldValue<System.Guid []>)
        else if t = typedefof<System.TimeSpan> then Some(wrap reader.GetTimeSpan)
        else if t = typedefof<System.TimeSpan []> then Some(wrap reader.GetFieldValue<System.TimeSpan []>)
        else if t = typedefof<System.DateOnly> then Some(wrap reader.GetDateOnly)
        else if t = typedefof<System.DateOnly []> then Some(wrap reader.GetFieldValue<System.DateOnly []>)
        else if t = typedefof<System.TimeOnly> then Some(wrap reader.GetTimeOnly)
        else if t = typedefof<System.TimeOnly []> then Some(wrap reader.GetFieldValue<System.TimeOnly []>)
        else if t = typedefof<System.DateTime> then Some(wrap reader.GetDateTime)
        else if t = typedefof<System.DateTime []> then Some(wrap reader.GetFieldValue<System.DateTime []>)
        else if t = typedefof<byte []> then Some(wrap reader.GetFieldValue<byte []>)
        else if t = typedefof<char> then Some(wrap reader.GetChar)
        else if t = typedefof<char []> then Some(wrap reader.GetFieldValue<char []>)
        else None

    static member Read(reader: Npgsql.NpgsqlDataReader) = 
        let hydra = HydraReader(reader)
                    
        let getOrdinalAndIncrement() = 
            let ordinal = hydra.AccFieldCount
            hydra.AccFieldCount <- hydra.AccFieldCount + 1
            ordinal
            
        let buildEntityReadFn (t: System.Type) = 
            let t, isOpt = 
                if t.IsGenericType && t.GetGenericTypeDefinition() = typedefof<Option<_>> 
                then t.GenericTypeArguments.[0], true
                else t, false
            
            match HydraReader.GetPrimitiveReader(t, reader, isOpt) with
            | Some primitiveReader -> 
                let ord = getOrdinalAndIncrement()
                fun () -> primitiveReader ord
            | None ->
                let nameParts = t.FullName.Split([| '.'; '+' |])
                let schemaAndType = nameParts |> Array.skip (nameParts.Length - 2) |> fun parts -> System.String.Join(".", parts)
                hydra.GetReaderByName(schemaAndType, isOpt)
            
        // Return a fn that will hydrate 'T (which may be a tuple)
        // This fn will be called once per each record returned by the data reader.
        let t = typeof<'T>
        if FSharp.Reflection.FSharpType.IsTuple(t) then
            let readEntityFns = FSharp.Reflection.FSharpType.GetTupleElements(t) |> Array.map buildEntityReadFn
            fun () ->
                let entities = readEntityFns |> Array.map (fun read -> read())
                Microsoft.FSharp.Reflection.FSharpValue.MakeTuple(entities, t) :?> 'T
        else
            let readEntityFn = t |> buildEntityReadFn
            fun () -> 
                readEntityFn() :?> 'T
        
