{
  "version": "6",
  "dialect": "sqlite",
  "id": "41342657-afb5-479d-bc93-2ba8d784c09b",
  "prevId": "b6f1ee4b-cc31-4060-a4d4-bcd4fdc5bd87",
  "tables": {
    "dose_tracking": {
      "name": "dose_tracking",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "dose_id": {
          "name": "dose_id",
          "type": "text(255)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "taken_at": {
          "name": "taken_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "(strftime('%s','now'))"
        },
        "marked_by": {
          "name": "marked_by",
          "type": "text(100)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "taken_source": {
          "name": "taken_source",
          "type": "text(20)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'manual'"
        },
        "dismissed": {
          "name": "dismissed",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "dose_tracking_user_id_users_id_fk": {
          "name": "dose_tracking_user_id_users_id_fk",
          "tableFrom": "dose_tracking",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "medications": {
      "name": "medications",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text(100)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "generic_name": {
          "name": "generic_name",
          "type": "text(100)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "taken_by_json": {
          "name": "taken_by_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "package_type": {
          "name": "package_type",
          "type": "text(20)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'blister'"
        },
        "pack_count": {
          "name": "pack_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "blisters_per_pack": {
          "name": "blisters_per_pack",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "pills_per_blister": {
          "name": "pills_per_blister",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "total_pills": {
          "name": "total_pills",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "loose_tablets": {
          "name": "loose_tablets",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "stock_adjustment": {
          "name": "stock_adjustment",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "last_stock_correction_at": {
          "name": "last_stock_correction_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "pill_weight_mg": {
          "name": "pill_weight_mg",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "dose_unit": {
          "name": "dose_unit",
          "type": "text(20)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false,
          "default": "'mg'"
        },
        "usage_json": {
          "name": "usage_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "every_json": {
          "name": "every_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "start_json": {
          "name": "start_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "intakes_json": {
          "name": "intakes_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "image_url": {
          "name": "image_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "expiry_date": {
          "name": "expiry_date",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "notes": {
          "name": "notes",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "intake_reminders_enabled": {
          "name": "intake_reminders_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "medication_start_date": {
          "name": "medication_start_date",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "is_obsolete": {
          "name": "is_obsolete",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "obsolete_at": {
          "name": "obsolete_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "prescription_enabled": {
          "name": "prescription_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "prescription_authorized_refills": {
          "name": "prescription_authorized_refills",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "prescription_remaining_refills": {
          "name": "prescription_remaining_refills",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "prescription_low_refill_threshold": {
          "name": "prescription_low_refill_threshold",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "prescription_expiry_date": {
          "name": "prescription_expiry_date",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "dismissed_until": {
          "name": "dismissed_until",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "medications_user_id_users_id_fk": {
          "name": "medications_user_id_users_id_fk",
          "tableFrom": "medications",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "refill_history": {
      "name": "refill_history",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "medication_id": {
          "name": "medication_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "packs_added": {
          "name": "packs_added",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "loose_pills_added": {
          "name": "loose_pills_added",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "used_prescription": {
          "name": "used_prescription",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "refill_date": {
          "name": "refill_date",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "(strftime('%s','now'))"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "refill_history_medication_id_medications_id_fk": {
          "name": "refill_history_medication_id_medications_id_fk",
          "tableFrom": "refill_history",
          "tableTo": "medications",
          "columnsFrom": [
            "medication_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "refill_history_user_id_users_id_fk": {
          "name": "refill_history_user_id_users_id_fk",
          "tableFrom": "refill_history",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "refresh_tokens": {
      "name": "refresh_tokens",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "token_id": {
          "name": "token_id",
          "type": "text(255)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "rotated_at": {
          "name": "rotated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "revoked": {
          "name": "revoked",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "refresh_tokens_token_id_unique": {
          "name": "refresh_tokens_token_id_unique",
          "columns": [
            "token_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "refresh_tokens_user_id_users_id_fk": {
          "name": "refresh_tokens_user_id_users_id_fk",
          "tableFrom": "refresh_tokens",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "share_tokens": {
      "name": "share_tokens",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "token": {
          "name": "token",
          "type": "text(64)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "taken_by": {
          "name": "taken_by",
          "type": "text(100)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "schedule_days": {
          "name": "schedule_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "share_tokens_token_unique": {
          "name": "share_tokens_token_unique",
          "columns": [
            "token"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "share_tokens_user_id_users_id_fk": {
          "name": "share_tokens_user_id_users_id_fk",
          "tableFrom": "share_tokens",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "user_settings": {
      "name": "user_settings",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email_enabled": {
          "name": "email_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "notification_email": {
          "name": "notification_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "email_stock_reminders": {
          "name": "email_stock_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "email_intake_reminders": {
          "name": "email_intake_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "email_prescription_reminders": {
          "name": "email_prescription_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "shoutrrr_enabled": {
          "name": "shoutrrr_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "shoutrrr_url": {
          "name": "shoutrrr_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "shoutrrr_stock_reminders": {
          "name": "shoutrrr_stock_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "shoutrrr_intake_reminders": {
          "name": "shoutrrr_intake_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "shoutrrr_prescription_reminders": {
          "name": "shoutrrr_prescription_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "reminder_days_before": {
          "name": "reminder_days_before",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 7
        },
        "repeat_daily_reminders": {
          "name": "repeat_daily_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "skip_reminders_for_taken_doses": {
          "name": "skip_reminders_for_taken_doses",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "repeat_reminders_enabled": {
          "name": "repeat_reminders_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "reminder_repeat_interval_minutes": {
          "name": "reminder_repeat_interval_minutes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "max_nagging_reminders": {
          "name": "max_nagging_reminders",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 5
        },
        "low_stock_days": {
          "name": "low_stock_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "normal_stock_days": {
          "name": "normal_stock_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 90
        },
        "high_stock_days": {
          "name": "high_stock_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 180
        },
        "expiry_warning_days": {
          "name": "expiry_warning_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 90
        },
        "language": {
          "name": "language",
          "type": "text(10)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'en'"
        },
        "stock_calculation_mode": {
          "name": "stock_calculation_mode",
          "type": "text(20)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'automatic'"
        },
        "share_stock_status": {
          "name": "share_stock_status",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "upcoming_today_only": {
          "name": "upcoming_today_only",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "share_schedule_today_only": {
          "name": "share_schedule_today_only",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "swap_dashboard_main_sections": {
          "name": "swap_dashboard_main_sections",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "last_auto_email_sent": {
          "name": "last_auto_email_sent",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_notification_type": {
          "name": "last_notification_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_notification_channel": {
          "name": "last_notification_channel",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_reminder_med_name": {
          "name": "last_reminder_med_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_reminder_taken_by": {
          "name": "last_reminder_taken_by",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_stock_reminder_sent": {
          "name": "last_stock_reminder_sent",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_stock_reminder_channel": {
          "name": "last_stock_reminder_channel",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_stock_reminder_med_names": {
          "name": "last_stock_reminder_med_names",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_prescription_reminder_sent": {
          "name": "last_prescription_reminder_sent",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_prescription_reminder_channel": {
          "name": "last_prescription_reminder_channel",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_prescription_reminder_med_names": {
          "name": "last_prescription_reminder_med_names",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "user_settings_user_id_unique": {
          "name": "user_settings_user_id_unique",
          "columns": [
            "user_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "user_settings_user_id_users_id_fk": {
          "name": "user_settings_user_id_users_id_fk",
          "tableFrom": "user_settings",
          "tableTo": "users",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "users": {
      "name": "users",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "username": {
          "name": "username",
          "type": "text(100)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "password_hash": {
          "name": "password_hash",
          "type": "text(255)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "avatar_url": {
          "name": "avatar_url",
          "type": "text(255)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "auth_provider": {
          "name": "auth_provider",
          "type": "text(50)",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'local'"
        },
        "oidc_subject": {
          "name": "oidc_subject",
          "type": "text(255)",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "is_active": {
          "name": "is_active",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "last_login_at": {
          "name": "last_login_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "users_username_unique": {
          "name": "users_username_unique",
          "columns": [
            "username"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    }
  },
  "views": {},
  "enums": {},
  "_meta": {
    "schemas": {},
    "tables": {},
    "columns": {}
  },
  "internal": {
    "indexes": {}
  }
}