Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ client/browser/build
**/package.json
**/coverage
internal/db/schema.md
internal/db/schema.*.md
cmd/xlang-python/python-langserver/
package-lock.json
package.json
Expand Down
3 changes: 2 additions & 1 deletion internal/db/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package db

// $PGHOST, $PGUSER, $PGPORT etc. must be set to run this generate script.
//go:generate env GO111MODULE=on go run schemadoc/main.go schema.md
//go:generate env GO111MODULE=on go run schemadoc/main.go frontend schema.md
//go:generate env GO111MODULE=on go run schemadoc/main.go codeintel schema.codeintel.md
71 changes: 71 additions & 0 deletions internal/db/schema.codeintel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Table "public.codeintel_schema_migrations"
```
Column | Type | Modifiers
---------+---------+-----------
version | bigint | not null
dirty | boolean | not null
Indexes:
"codeintel_schema_migrations_pkey" PRIMARY KEY, btree (version)

```

# Table "public.lsif_data_definitions"
```
Column | Type | Modifiers
------------+---------+-----------
dump_id | integer | not null
scheme | text | not null
identifier | text | not null
data | bytea |
Indexes:
"lsif_data_definitions_pkey" PRIMARY KEY, btree (dump_id, scheme, identifier)

```

# Table "public.lsif_data_documents"
```
Column | Type | Modifiers
---------+---------+-----------
dump_id | integer | not null
path | text | not null
data | bytea |
Indexes:
"lsif_data_documents_pkey" PRIMARY KEY, btree (dump_id, path)

```

# Table "public.lsif_data_metadata"
```
Column | Type | Modifiers
-------------------+---------+-----------
dump_id | integer | not null
num_result_chunks | integer |
Indexes:
"lsif_data_metadata_pkey" PRIMARY KEY, btree (dump_id)

```

# Table "public.lsif_data_references"
```
Column | Type | Modifiers
------------+---------+-----------
dump_id | integer | not null
scheme | text | not null
identifier | text | not null
data | bytea |
Indexes:
"lsif_data_references_pkey" PRIMARY KEY, btree (dump_id, scheme, identifier)

```

# Table "public.lsif_data_result_chunks"
```
Column | Type | Modifiers
---------+---------+-----------
dump_id | integer | not null
idx | integer | not null
data | bytea |
Indexes:
"lsif_data_result_chunks_pkey" PRIMARY KEY, btree (dump_id, idx)

```
72 changes: 0 additions & 72 deletions internal/db/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,6 @@ Referenced by:

```

# Table "public.codeintel_schema_migrations"
```
Column | Type | Modifiers
---------+---------+-----------
version | bigint | not null
dirty | boolean | not null
Indexes:
"codeintel_schema_migrations_pkey" PRIMARY KEY, btree (version)

```

# Table "public.critical_and_site_config"
```
Column | Type | Modifiers
Expand Down Expand Up @@ -574,67 +563,6 @@ Indexes:

```

# Table "public.lsif_data_definitions"
```
Column | Type | Modifiers
------------+---------+-----------
dump_id | integer | not null
scheme | text | not null
identifier | text | not null
data | bytea |
Indexes:
"lsif_data_definitions_pkey" PRIMARY KEY, btree (dump_id, scheme, identifier)

```

# Table "public.lsif_data_documents"
```
Column | Type | Modifiers
---------+---------+-----------
dump_id | integer | not null
path | text | not null
data | bytea |
Indexes:
"lsif_data_documents_pkey" PRIMARY KEY, btree (dump_id, path)

```

# Table "public.lsif_data_metadata"
```
Column | Type | Modifiers
-------------------+---------+-----------
dump_id | integer | not null
num_result_chunks | integer |
Indexes:
"lsif_data_metadata_pkey" PRIMARY KEY, btree (dump_id)

```

# Table "public.lsif_data_references"
```
Column | Type | Modifiers
------------+---------+-----------
dump_id | integer | not null
scheme | text | not null
identifier | text | not null
data | bytea |
Indexes:
"lsif_data_references_pkey" PRIMARY KEY, btree (dump_id, scheme, identifier)

```

# Table "public.lsif_data_result_chunks"
```
Column | Type | Modifiers
---------+---------+-----------
dump_id | integer | not null
idx | integer | not null
data | bytea |
Indexes:
"lsif_data_result_chunks_pkey" PRIMARY KEY, btree (dump_id, idx)

```

# Table "public.lsif_dirty_repositories"
```
Column | Type | Modifiers
Expand Down
15 changes: 5 additions & 10 deletions internal/db/schemadoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/sourcegraph/sourcegraph/internal/db/dbconn"
"github.com/sourcegraph/sourcegraph/internal/db/dbutil"
"github.com/sourcegraph/sourcegraph/internal/lazyregexp"

_ "github.com/lib/pq"
Expand All @@ -27,7 +26,7 @@ func runIgnoreError(cmd string, args ...string) {
// PGPORT, PGUSER etc. env variables must be set to run this script.
//
// First CLI argument is an optional filename to write the output to.
func generate(log *log.Logger) (string, error) {
func generate(log *log.Logger, databaseName string) (string, error) {
const dbname = "schemadoc-gen-temp"

var (
Expand Down Expand Up @@ -99,12 +98,8 @@ func generate(log *log.Logger) (string, error) {
return "", fmt.Errorf("SetupGlobalConnection: %w", err)
}

// Migrate the codeintel db on top of the frontend one so we capture
// the schema of both databases.
for _, databaseName := range dbutil.DatabaseNames {
if err := dbconn.MigrateDB(dbconn.Global, databaseName); err != nil {
return "", fmt.Errorf("MigrateDB: %w", err)
}
if err := dbconn.MigrateDB(dbconn.Global, databaseName); err != nil {
return "", fmt.Errorf("MigrateDB: %w", err)
}

db, err := dbconn.Open(dataSource)
Expand Down Expand Up @@ -155,12 +150,12 @@ WHERE table_schema='public' AND table_type='BASE TABLE';
}

func main() {
out, err := generate(log.New(os.Stderr, "", log.LstdFlags))
out, err := generate(log.New(os.Stderr, "", log.LstdFlags), os.Args[1])
if err != nil {
log.Fatal(err)
}
if len(os.Args) > 1 {
if err := ioutil.WriteFile(os.Args[1], []byte(out), 0644); err != nil {
if err := ioutil.WriteFile(os.Args[2], []byte(out), 0644); err != nil {
log.Fatal(err)
}
} else {
Expand Down