export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  public: {
    Tables: {
      apiKey: {
        Row: {
          createdAt: string
          id: string
          keyHash: string
          keyId: string
          name: string
          userId: string | null
        }
        Insert: {
          createdAt?: string
          id: string
          keyHash: string
          keyId: string
          name: string
          userId?: string | null
        }
        Update: {
          createdAt?: string
          id?: string
          keyHash?: string
          keyId?: string
          name?: string
          userId?: string | null
        }
        Relationships: []
      }
      categories: {
        Row: {
          code: number
          colorId: string
          createdAt: string
          description: string | null
          id: string
          name: string
          parentId: string | null
          userId: string | null
        }
        Insert: {
          code: number
          colorId: string
          createdAt?: string
          description?: string | null
          id: string
          name: string
          parentId?: string | null
          userId?: string | null
        }
        Update: {
          code?: number
          colorId?: string
          createdAt?: string
          description?: string | null
          id?: string
          name?: string
          parentId?: string | null
          userId?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "category_colorId_color_id_fk"
            columns: ["colorId"]
            isOneToOne: false
            referencedRelation: "colors"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "category_parentId_category_id_fk"
            columns: ["parentId"]
            isOneToOne: false
            referencedRelation: "categories"
            referencedColumns: ["id"]
          },
        ]
      }
      colors: {
        Row: {
          createdAt: string
          hexcode: string
          id: string
          inverse: string | null
          name: string
          userId: string | null
        }
        Insert: {
          createdAt?: string
          hexcode: string
          id: string
          inverse?: string | null
          name: string
          userId?: string | null
        }
        Update: {
          createdAt?: string
          hexcode?: string
          id?: string
          inverse?: string | null
          name?: string
          userId?: string | null
        }
        Relationships: []
      }
      days: {
        Row: {
          comment: string | null
          date: string
          id: string
          mood: number | null
          userId: string | null
        }
        Insert: {
          comment?: string | null
          date: string
          id: string
          mood?: number | null
          userId?: string | null
        }
        Update: {
          comment?: string | null
          date?: string
          id?: string
          mood?: number | null
          userId?: string | null
        }
        Relationships: []
      }
      hours: {
        Row: {
          categoryId: string | null
          comment: string | null
          createdAt: string
          datetime: string | null
          dayId: string
          id: string
          userId: string | null
        }
        Insert: {
          categoryId?: string | null
          comment?: string | null
          createdAt?: string
          datetime?: string | null
          dayId: string
          id: string
          userId?: string | null
        }
        Update: {
          categoryId?: string | null
          comment?: string | null
          createdAt?: string
          datetime?: string | null
          dayId?: string
          id?: string
          userId?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "hour_categoryId_category_id_fk"
            columns: ["categoryId"]
            isOneToOne: false
            referencedRelation: "categories"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "hour_dayId_day_id_fk"
            columns: ["dayId"]
            isOneToOne: false
            referencedRelation: "days"
            referencedColumns: ["id"]
          },
        ]
      }
      measurements: {
        Row: {
          createdAt: string
          dayId: string
          hourId: string | null
          id: string
          metricId: string
          userId: string | null
          value: string
        }
        Insert: {
          createdAt?: string
          dayId: string
          hourId?: string | null
          id: string
          metricId: string
          userId?: string | null
          value: string
        }
        Update: {
          createdAt?: string
          dayId?: string
          hourId?: string | null
          id?: string
          metricId?: string
          userId?: string | null
          value?: string
        }
        Relationships: [
          {
            foreignKeyName: "measurement_dayId_day_id_fk"
            columns: ["dayId"]
            isOneToOne: false
            referencedRelation: "days"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "measurement_hourId_hour_id_fk"
            columns: ["hourId"]
            isOneToOne: false
            referencedRelation: "hours"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "measurement_metricId_metric_id_fk"
            columns: ["metricId"]
            isOneToOne: false
            referencedRelation: "metrics"
            referencedColumns: ["id"]
          },
        ]
      }
      metrics: {
        Row: {
          createdAt: string
          description: string | null
          goal: number | null
          icon: string
          id: string
          name: string
          type: string
          unit: string | null
          userId: string | null
        }
        Insert: {
          createdAt?: string
          description?: string | null
          goal?: number | null
          icon: string
          id: string
          name: string
          type: string
          unit?: string | null
          userId?: string | null
        }
        Update: {
          createdAt?: string
          description?: string | null
          goal?: number | null
          icon?: string
          id?: string
          name?: string
          type?: string
          unit?: string | null
          userId?: string | null
        }
        Relationships: []
      }
      sb_categories: {
        Row: {
          code: number
          colorId: number
          created_at: string
          id: number
          name: string
          userId: string
        }
        Insert: {
          code: number
          colorId: number
          created_at?: string
          id?: number
          name: string
          userId: string
        }
        Update: {
          code?: number
          colorId?: number
          created_at?: string
          id?: number
          name?: string
          userId?: string
        }
        Relationships: [
          {
            foreignKeyName: "categories_colorId_fkey"
            columns: ["colorId"]
            isOneToOne: false
            referencedRelation: "sb_colors"
            referencedColumns: ["id"]
          },
        ]
      }
      sb_colors: {
        Row: {
          hexcode: string
          id: number
          inverse: string
          name: string
          userId: string
        }
        Insert: {
          hexcode: string
          id?: number
          inverse: string
          name: string
          userId: string
        }
        Update: {
          hexcode?: string
          id?: number
          inverse?: string
          name?: string
          userId?: string
        }
        Relationships: []
      }
      sb_days: {
        Row: {
          comment: string | null
          date: string
          id: number
          mood: number | null
          userId: string
        }
        Insert: {
          comment?: string | null
          date: string
          id?: number
          mood?: number | null
          userId: string
        }
        Update: {
          comment?: string | null
          date?: string
          id?: number
          mood?: number | null
          userId?: string
        }
        Relationships: []
      }
      sb_hours: {
        Row: {
          categoryId: number | null
          comment: string | null
          datetime: string
          dayId: number
          id: number
          userId: string | null
        }
        Insert: {
          categoryId?: number | null
          comment?: string | null
          datetime: string
          dayId: number
          id?: number
          userId?: string | null
        }
        Update: {
          categoryId?: number | null
          comment?: string | null
          datetime?: string
          dayId?: number
          id?: number
          userId?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "hours_dayId_fkey"
            columns: ["dayId"]
            isOneToOne: false
            referencedRelation: "sb_days"
            referencedColumns: ["id"]
          },
        ]
      }
      sb_measurements: {
        Row: {
          created_at: string
          dayId: number | null
          hourId: number | null
          id: number
          metricId: number | null
          type: string
          userId: string | null
          value: string
        }
        Insert: {
          created_at?: string
          dayId?: number | null
          hourId?: number | null
          id?: number
          metricId?: number | null
          type?: string
          userId?: string | null
          value: string
        }
        Update: {
          created_at?: string
          dayId?: number | null
          hourId?: number | null
          id?: number
          metricId?: number | null
          type?: string
          userId?: string | null
          value?: string
        }
        Relationships: [
          {
            foreignKeyName: "measurements_dayId_fkey"
            columns: ["dayId"]
            isOneToOne: false
            referencedRelation: "sb_days"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "measurements_hourId_fkey"
            columns: ["hourId"]
            isOneToOne: false
            referencedRelation: "sb_hours"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "measurements_metricId_fkey"
            columns: ["metricId"]
            isOneToOne: false
            referencedRelation: "sb_metrics"
            referencedColumns: ["id"]
          },
        ]
      }
      sb_metrics: {
        Row: {
          created_at: string
          description: string | null
          goal: number | null
          icon: string
          id: number
          name: string
          type: string
          unit: string | null
          userId: string
        }
        Insert: {
          created_at?: string
          description?: string | null
          goal?: number | null
          icon: string
          id?: number
          name: string
          type: string
          unit?: string | null
          userId: string
        }
        Update: {
          created_at?: string
          description?: string | null
          goal?: number | null
          icon?: string
          id?: number
          name?: string
          type?: string
          unit?: string | null
          userId?: string
        }
        Relationships: []
      }
      user: {
        Row: {
          email: string
          emailVerified: number | null
          id: string
          image: string | null
          name: string
          password: string | null
          role: string | null
          timezone: string
        }
        Insert: {
          email: string
          emailVerified?: number | null
          id: string
          image?: string | null
          name: string
          password?: string | null
          role?: string | null
          timezone?: string
        }
        Update: {
          email?: string
          emailVerified?: number | null
          id?: string
          image?: string | null
          name?: string
          password?: string | null
          role?: string | null
          timezone?: string
        }
        Relationships: []
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      [_ in never]: never
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

type PublicSchema = Database[Extract<keyof Database, "public">]

export type Tables<
  PublicTableNameOrOptions extends
    | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
    | { schema: keyof Database },
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
    ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
        Database[PublicTableNameOrOptions["schema"]]["Views"])
    : never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
  ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
      Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
      Row: infer R
    }
    ? R
    : never
  : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
        PublicSchema["Views"])
    ? (PublicSchema["Tables"] &
        PublicSchema["Views"])[PublicTableNameOrOptions] extends {
        Row: infer R
      }
      ? R
      : never
    : never

export type TablesInsert<
  PublicTableNameOrOptions extends
    | keyof PublicSchema["Tables"]
    | { schema: keyof Database },
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
    ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
  ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Insert: infer I
    }
    ? I
    : never
  : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
    ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
        Insert: infer I
      }
      ? I
      : never
    : never

export type TablesUpdate<
  PublicTableNameOrOptions extends
    | keyof PublicSchema["Tables"]
    | { schema: keyof Database },
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
    ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
  ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Update: infer U
    }
    ? U
    : never
  : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
    ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
        Update: infer U
      }
      ? U
      : never
    : never

export type Enums<
  PublicEnumNameOrOptions extends
    | keyof PublicSchema["Enums"]
    | { schema: keyof Database },
  EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
    ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
    : never = never,
> = PublicEnumNameOrOptions extends { schema: keyof Database }
  ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
  : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
    ? PublicSchema["Enums"][PublicEnumNameOrOptions]
    : never

export type CompositeTypes<
  PublicCompositeTypeNameOrOptions extends
    | keyof PublicSchema["CompositeTypes"]
    | { schema: keyof Database },
  CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
    schema: keyof Database
  }
    ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
    : never = never,
> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
  ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
  : PublicCompositeTypeNameOrOptions extends keyof PublicSchema["CompositeTypes"]
    ? PublicSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
    : never
