Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 146 additions & 1 deletion packages/bruno-sqlite/SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Generated by `npm run schema` from `migrations/` — do not edit by hand.

Migrations applied: `0000001_runner_responses`, `0000002_file_index_entries`, `0000003_files`, `0000004_runner_response_files`, `0000005_runner_response_iteration_index`
Migrations applied: `0000001_runner_responses`, `0000002_file_index_entries`, `0000003_files`, `0000004_runner_response_files`, `0000005_runner_response_iteration_index`, `0000007_github_discovery`

```mermaid
erDiagram
Expand All @@ -28,6 +28,60 @@ erDiagram
INTEGER created_at "NOT NULL"
INTEGER updated_at "NOT NULL"
}
gh_account {
INTEGER id PK
TEXT host "NOT NULL"
INTEGER user_id "NOT NULL"
TEXT login "NOT NULL"
TEXT token_hash "NOT NULL"
INTEGER updated_at "NOT NULL"
}
gh_collections {
INTEGER id PK
INTEGER repo_id "NOT NULL"
TEXT folder_path "NOT NULL"
TEXT manifest_path "NOT NULL"
TEXT kind "NOT NULL"
TEXT blob_oid
INTEGER request_count
INTEGER last_seen "NOT NULL"
}
gh_names {
TEXT blob_oid PK
TEXT name
INTEGER last_seen "NOT NULL"
}
gh_queries {
TEXT query_key PK
TEXT kind "NOT NULL"
INTEGER result_count "NOT NULL"
INTEGER total
INTEGER has_next "NOT NULL"
INTEGER incomplete "NOT NULL"
INTEGER searched_at "NOT NULL"
INTEGER last_seen "NOT NULL"
}
gh_query_items {
TEXT query_key PK
INTEGER position PK
INTEGER repo_id
INTEGER collection_id
}
gh_repos {
INTEGER repo_id PK
TEXT full_name "NOT NULL"
TEXT owner "NOT NULL"
TEXT name "NOT NULL"
TEXT description
TEXT avatar_url
TEXT visibility
INTEGER is_private "NOT NULL"
INTEGER is_archived "NOT NULL"
TEXT default_branch
TEXT tree_etag
INTEGER tree_checked_at
INTEGER last_seen "NOT NULL"
}
runner_responses {
TEXT request_uid PK
TEXT collection_uid "NOT NULL"
Expand Down Expand Up @@ -77,6 +131,97 @@ erDiagram
| `created_at` | INTEGER | yes | `unixepoch()` | |
| `updated_at` | INTEGER | yes | `unixepoch()` | |

## `gh_account`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `id` | INTEGER | | | PK |
| `host` | TEXT | yes | | |
| `user_id` | INTEGER | yes | | |
| `login` | TEXT | yes | | |
| `token_hash` | TEXT | yes | | |
| `updated_at` | INTEGER | yes | | |

## `gh_collections`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `id` | INTEGER | | | PK |
| `repo_id` | INTEGER | yes | | |
| `folder_path` | TEXT | yes | | |
| `manifest_path` | TEXT | yes | | |
| `kind` | TEXT | yes | | |
| `blob_oid` | TEXT | | | |
| `request_count` | INTEGER | | | |
| `last_seen` | INTEGER | yes | | |

**Indexes**

- `idx_gh_collections_last_seen` on (`last_seen`)

## `gh_names`

`WITHOUT ROWID`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `blob_oid` | TEXT | yes | | PK |
| `name` | TEXT | | | |
| `last_seen` | INTEGER | yes | | |

## `gh_queries`

`WITHOUT ROWID`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `query_key` | TEXT | yes | | PK |
| `kind` | TEXT | yes | | |
| `result_count` | INTEGER | yes | | |
| `total` | INTEGER | | | |
| `has_next` | INTEGER | yes | | |
| `incomplete` | INTEGER | yes | | |
| `searched_at` | INTEGER | yes | | |
| `last_seen` | INTEGER | yes | | |

**Indexes**

- `idx_gh_queries_last_seen` on (`last_seen`)

## `gh_query_items`

`WITHOUT ROWID`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `query_key` | TEXT | yes | | PK (1) |
| `position` | INTEGER | yes | | PK (2) |
| `repo_id` | INTEGER | | | |
| `collection_id` | INTEGER | | | |

## `gh_repos`

| Column | Type | Not null | Default | Key |
|---|---|---|---|---|
| `repo_id` | INTEGER | | | PK |
| `full_name` | TEXT | yes | | |
| `owner` | TEXT | yes | | |
| `name` | TEXT | yes | | |
| `description` | TEXT | | | |
| `avatar_url` | TEXT | | | |
| `visibility` | TEXT | | | |
| `is_private` | INTEGER | yes | | |
| `is_archived` | INTEGER | yes | `0` | |
| `default_branch` | TEXT | | | |
| `tree_etag` | TEXT | | | |
| `tree_checked_at` | INTEGER | | | |
| `last_seen` | INTEGER | yes | | |

**Indexes**

- `idx_gh_repos_full_name` on (`full_name`)
- `idx_gh_repos_last_seen` on (`last_seen`)

## `runner_responses`

| Column | Type | Not null | Default | Key |
Expand Down
87 changes: 87 additions & 0 deletions packages/bruno-sqlite/migrations/0000007_github_discovery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Owned by EE GitHub discovery: keep byte-identical with the EE copy. Times are epoch milliseconds.
Comment thread
sundram-bruno marked this conversation as resolved.
Resolved
export const up = (): string => {
return `
CREATE TABLE IF NOT EXISTS gh_account (
id INTEGER PRIMARY KEY CHECK (id = 1),
host TEXT NOT NULL,
user_id INTEGER NOT NULL,
login TEXT NOT NULL,
token_hash TEXT NOT NULL CHECK (length(token_hash) = 64),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
updated_at INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS gh_queries (
query_key TEXT PRIMARY KEY,
kind TEXT NOT NULL,
result_count INTEGER NOT NULL,
total INTEGER,
has_next INTEGER NOT NULL,
incomplete INTEGER NOT NULL,
searched_at INTEGER NOT NULL,
last_seen INTEGER NOT NULL
) WITHOUT ROWID;

CREATE INDEX IF NOT EXISTS idx_gh_queries_last_seen ON gh_queries(last_seen);

CREATE TABLE IF NOT EXISTS gh_query_items (
query_key TEXT NOT NULL,
position INTEGER NOT NULL,
repo_id INTEGER,
collection_id INTEGER,
PRIMARY KEY (query_key, position),
CHECK ((repo_id IS NULL) <> (collection_id IS NULL))
) WITHOUT ROWID;

CREATE TABLE IF NOT EXISTS gh_repos (
repo_id INTEGER PRIMARY KEY,
full_name TEXT NOT NULL COLLATE NOCASE,
owner TEXT NOT NULL,
name TEXT NOT NULL,
description TEXT,
avatar_url TEXT,
visibility TEXT,
is_private INTEGER NOT NULL CHECK (is_private IN (0, 1)),
is_archived INTEGER NOT NULL DEFAULT 0,
default_branch TEXT,
tree_etag TEXT,
tree_checked_at INTEGER,
last_seen INTEGER NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_gh_repos_last_seen ON gh_repos(last_seen);
CREATE INDEX IF NOT EXISTS idx_gh_repos_full_name ON gh_repos(full_name COLLATE NOCASE);

CREATE TABLE IF NOT EXISTS gh_collections (
id INTEGER PRIMARY KEY AUTOINCREMENT,
repo_id INTEGER NOT NULL,
folder_path TEXT NOT NULL,
manifest_path TEXT NOT NULL,
kind TEXT NOT NULL,
blob_oid TEXT,
request_count INTEGER,
last_seen INTEGER NOT NULL,
UNIQUE (repo_id, folder_path)
);

CREATE INDEX IF NOT EXISTS idx_gh_collections_last_seen ON gh_collections(last_seen);

CREATE TABLE IF NOT EXISTS gh_names (
blob_oid TEXT PRIMARY KEY,
name TEXT,
last_seen INTEGER NOT NULL
) WITHOUT ROWID;
`;
};

export const down = (): string => {
return `
PRAGMA secure_delete = ON;
DROP TABLE IF EXISTS gh_names;
DROP TABLE IF EXISTS gh_collections;
DROP TABLE IF EXISTS gh_repos;
DROP TABLE IF EXISTS gh_query_items;
DROP TABLE IF EXISTS gh_queries;
DROP TABLE IF EXISTS gh_account;
PRAGMA secure_delete = OFF;
`;
};
Loading
Loading