diff --git a/.prettierignore b/.prettierignore index 482ba9852a4b..92d0e17ed239 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/internal/db/gen.go b/internal/db/gen.go index 40b222566764..df0b1d5a4a0c 100644 --- a/internal/db/gen.go +++ b/internal/db/gen.go @@ -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 diff --git a/internal/db/schema.codeintel.md b/internal/db/schema.codeintel.md new file mode 100644 index 000000000000..9baeab634d3c --- /dev/null +++ b/internal/db/schema.codeintel.md @@ -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) + +``` diff --git a/internal/db/schema.md b/internal/db/schema.md index 47c00ddfc3f8..9302d25d109e 100644 --- a/internal/db/schema.md +++ b/internal/db/schema.md @@ -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 @@ -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 diff --git a/internal/db/schemadoc/main.go b/internal/db/schemadoc/main.go index 5fb970598b18..a30201d3aaf0 100644 --- a/internal/db/schemadoc/main.go +++ b/internal/db/schemadoc/main.go @@ -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" @@ -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 ( @@ -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) @@ -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 {