{
  "id": "54aa77f5-cee4-419c-8c48-0d0b4b5194bc",
  "prevId": "bdfafee4-65d2-4381-b4e7-df8c9337d0c1",
  "version": "7",
  "dialect": "postgresql",
  "tables": {
    "public.tenant": {
      "name": "tenant",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "short_name": {
          "name": "short_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "long_name": {
          "name": "long_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "logo": {
          "name": "logo",
          "type": "bytea",
          "primaryKey": false,
          "notNull": false
        },
        "database_url": {
          "name": "database_url",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "setup_state": {
          "name": "setup_state",
          "type": "setup_state",
          "typeSchema": "public",
          "primaryKey": false,
          "notNull": true,
          "default": "'NEW'"
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        }
      },
      "indexes": {
        "tenant_database_url_idx": {
          "name": "tenant_database_url_idx",
          "columns": [
            {
              "expression": "database_url",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "tenant_short_name_unique": {
          "name": "tenant_short_name_unique",
          "nullsNotDistinct": false,
          "columns": ["short_name"]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.tenant_config": {
      "name": "tenant_config",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "tenant_id": {
          "name": "tenant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "type": {
          "name": "type",
          "type": "config_type",
          "typeSchema": "public",
          "primaryKey": false,
          "notNull": true
        },
        "value": {
          "name": "value",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        }
      },
      "indexes": {
        "tenant_config_tenant_name_idx": {
          "name": "tenant_config_tenant_name_idx",
          "columns": [
            {
              "expression": "tenant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            },
            {
              "expression": "name",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "tenant_config_tenant_id_tenant_id_fk": {
          "name": "tenant_config_tenant_id_tenant_id_fk",
          "tableFrom": "tenant_config",
          "tableTo": "tenant",
          "columnsFrom": ["tenant_id"],
          "columnsTo": ["id"],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.user": {
      "name": "user",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "role": {
          "name": "role",
          "type": "user_role",
          "typeSchema": "public",
          "primaryKey": false,
          "notNull": true,
          "default": "'STAFF'"
        },
        "tenant_id": {
          "name": "tenant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "last_login_at": {
          "name": "last_login_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false
        },
        "is_active": {
          "name": "is_active",
          "type": "boolean",
          "primaryKey": false,
          "notNull": false,
          "default": true
        },
        "confirmed": {
          "name": "confirmed",
          "type": "boolean",
          "primaryKey": false,
          "notNull": false,
          "default": false
        },
        "token": {
          "name": "token",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "token_valid_until": {
          "name": "token_valid_until",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false
        },
        "passphrase_hash": {
          "name": "passphrase_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "recovery_passphrase": {
          "name": "recovery_passphrase",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'de'"
        }
      },
      "indexes": {
        "user_email_idx": {
          "name": "user_email_idx",
          "columns": [
            {
              "expression": "email",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "user_tenant_id_tenant_id_fk": {
          "name": "user_tenant_id_tenant_id_fk",
          "tableFrom": "user",
          "tableTo": "tenant",
          "columnsFrom": ["tenant_id"],
          "columnsTo": ["id"],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "user_email_unique": {
          "name": "user_email_unique",
          "nullsNotDistinct": false,
          "columns": ["email"]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.user_invite": {
      "name": "user_invite",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "invite_code": {
          "name": "invite_code",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "role": {
          "name": "role",
          "type": "user_role",
          "typeSchema": "public",
          "primaryKey": false,
          "notNull": true
        },
        "tenant_id": {
          "name": "tenant_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "invited_by": {
          "name": "invited_by",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "default": "'de'"
        },
        "used": {
          "name": "used",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "used_at": {
          "name": "used_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false
        },
        "created_user_id": {
          "name": "created_user_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": true
        }
      },
      "indexes": {
        "user_invite_code_idx": {
          "name": "user_invite_code_idx",
          "columns": [
            {
              "expression": "invite_code",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "user_invite_email_idx": {
          "name": "user_invite_email_idx",
          "columns": [
            {
              "expression": "email",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "user_invite_tenant_idx": {
          "name": "user_invite_tenant_idx",
          "columns": [
            {
              "expression": "tenant_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "user_invite_tenant_id_tenant_id_fk": {
          "name": "user_invite_tenant_id_tenant_id_fk",
          "tableFrom": "user_invite",
          "tableTo": "tenant",
          "columnsFrom": ["tenant_id"],
          "columnsTo": ["id"],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "user_invite_invited_by_user_id_fk": {
          "name": "user_invite_invited_by_user_id_fk",
          "tableFrom": "user_invite",
          "tableTo": "user",
          "columnsFrom": ["invited_by"],
          "columnsTo": ["id"],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "user_invite_created_user_id_user_id_fk": {
          "name": "user_invite_created_user_id_user_id_fk",
          "tableFrom": "user_invite",
          "tableTo": "user",
          "columnsFrom": ["created_user_id"],
          "columnsTo": ["id"],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "user_invite_invite_code_unique": {
          "name": "user_invite_invite_code_unique",
          "nullsNotDistinct": false,
          "columns": ["invite_code"]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.user_passkey": {
      "name": "user_passkey",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true
        },
        "user_id": {
          "name": "user_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "public_key": {
          "name": "public_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "counter": {
          "name": "counter",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "default": 0
        },
        "device_name": {
          "name": "device_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false
        }
      },
      "indexes": {
        "user_passkey_user_idx": {
          "name": "user_passkey_user_idx",
          "columns": [
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "user_passkey_user_id_user_id_fk": {
          "name": "user_passkey_user_id_user_id_fk",
          "tableFrom": "user_passkey",
          "tableTo": "user",
          "columnsFrom": ["user_id"],
          "columnsTo": ["id"],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    },
    "public.user_session": {
      "name": "user_session",
      "schema": "",
      "columns": {
        "id": {
          "name": "id",
          "type": "uuid",
          "primaryKey": true,
          "notNull": true,
          "default": "gen_random_uuid()"
        },
        "user_id": {
          "name": "user_id",
          "type": "uuid",
          "primaryKey": false,
          "notNull": true
        },
        "session_token": {
          "name": "session_token",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "access_token": {
          "name": "access_token",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "refresh_token": {
          "name": "refresh_token",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "ip_address": {
          "name": "ip_address",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "user_agent": {
          "name": "user_agent",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        },
        "expires_at": {
          "name": "expires_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": true
        },
        "last_used_at": {
          "name": "last_used_at",
          "type": "timestamp",
          "primaryKey": false,
          "notNull": false,
          "default": "now()"
        }
      },
      "indexes": {
        "user_session_user_idx": {
          "name": "user_session_user_idx",
          "columns": [
            {
              "expression": "user_id",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": false,
          "concurrently": false,
          "method": "btree",
          "with": {}
        },
        "user_session_token_idx": {
          "name": "user_session_token_idx",
          "columns": [
            {
              "expression": "session_token",
              "isExpression": false,
              "asc": true,
              "nulls": "last"
            }
          ],
          "isUnique": true,
          "concurrently": false,
          "method": "btree",
          "with": {}
        }
      },
      "foreignKeys": {
        "user_session_user_id_user_id_fk": {
          "name": "user_session_user_id_user_id_fk",
          "tableFrom": "user_session",
          "tableTo": "user",
          "columnsFrom": ["user_id"],
          "columnsTo": ["id"],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "user_session_session_token_unique": {
          "name": "user_session_session_token_unique",
          "nullsNotDistinct": false,
          "columns": ["session_token"]
        }
      },
      "policies": {},
      "checkConstraints": {},
      "isRLSEnabled": false
    }
  },
  "enums": {
    "public.config_type": {
      "name": "config_type",
      "schema": "public",
      "values": ["BOOLEAN", "NUMBER", "STRING"]
    },
    "public.setup_state": {
      "name": "setup_state",
      "schema": "public",
      "values": ["NEW", "SETTINGS_CREATED", "AGENTS_SET_UP", "FIRST_CHANNEL_CREATED"]
    },
    "public.user_role": {
      "name": "user_role",
      "schema": "public",
      "values": ["GLOBAL_ADMIN", "TENANT_ADMIN", "STAFF"]
    }
  },
  "schemas": {},
  "sequences": {},
  "roles": {},
  "policies": {},
  "views": {},
  "_meta": {
    "columns": {},
    "schemas": {},
    "tables": {}
  }
}
