Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf27e73d

Browse files
authored
chore(coderd/database/gen/dump): add optional DB_DUMP_CONNECTION_URL (#16243)
1 parent5f4ff58 commitf27e73d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎coderd/database/gen/dump/main.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"path/filepath"
88
"runtime"
99

10+
"golang.org/x/xerrors"
11+
1012
"github.com/coder/coder/v2/coderd/database/dbtestutil"
1113
"github.com/coder/coder/v2/coderd/database/migrations"
1214
)
@@ -37,25 +39,34 @@ func main() {
3739
}
3840
}()
3941

40-
connection,cleanup,err:=dbtestutil.OpenContainerized(t, dbtestutil.DBContainerOptions{})
41-
iferr!=nil {
42-
panic(err)
42+
connection:=os.Getenv("DB_DUMP_CONNECTION_URL")
43+
ifconnection=="" {
44+
varcleanupfunc()
45+
varerrerror
46+
connection,cleanup,err=dbtestutil.OpenContainerized(t, dbtestutil.DBContainerOptions{})
47+
iferr!=nil {
48+
err=xerrors.Errorf("open containerized database failed: %w",err)
49+
panic(err)
50+
}
51+
defercleanup()
4352
}
44-
defercleanup()
4553

4654
db,err:=sql.Open("postgres",connection)
4755
iferr!=nil {
56+
err=xerrors.Errorf("open database failed: %w",err)
4857
panic(err)
4958
}
5059
deferdb.Close()
5160

5261
err=migrations.Up(db)
5362
iferr!=nil {
63+
err=xerrors.Errorf("run migrations failed: %w",err)
5464
panic(err)
5565
}
5666

5767
dumpBytes,err:=dbtestutil.PGDumpSchemaOnly(connection)
5868
iferr!=nil {
69+
err=xerrors.Errorf("dump schema failed: %w",err)
5970
panic(err)
6071
}
6172

@@ -65,6 +76,7 @@ func main() {
6576
}
6677
err=os.WriteFile(filepath.Join(mainPath,"..","..","..","dump.sql"),append(preamble,dumpBytes...),0o600)
6778
iferr!=nil {
79+
err=xerrors.Errorf("write dump failed: %w",err)
6880
panic(err)
6981
}
7082
}

‎docs/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ the following tools by hand:
7272
-[`pg_dump`](https://stackoverflow.com/a/49689589)
7373
- on macOS, run`brew install libpq zstd`
7474
- on Linux, install[`zstd`](https://github.com/horta/zstd.install)
75+
- PostgreSQL 13 (optional if Docker is available)
76+
-*Note*: If you are using Docker, you can skip this step
77+
- on macOS, run`brew install postgresql@13` and`brew services start postgresql@13`
78+
- To enable schema generation with non-containerized PostgreSQL, set the following environment variable:
79+
-`export DB_DUMP_CONNECTION_URL="postgres://postgres@localhost:5432/postgres?password=postgres&sslmode=disable"`
7580
-`pkg-config`
7681
- on macOS, run`brew install pkg-config`
7782
-`pixman`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp