Skip to content
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
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,3 @@ Charts use the `LoadBalancer` service type by default, you can change this durin
```
--set service.type=ClusterIP
```

For any installation, the application database user must have privileges to create schemas in the database
(for example, the `CREATE` privilege on the database or the ability to run `CREATE SCHEMA`).
Database migrations will create and update all required tables and other objects in the `crosslink_broker` schema,
which is selected via the PostgreSQL `search_path`.
5 changes: 2 additions & 3 deletions broker/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ var DB_HOST = utils.GetEnv("DB_HOST", "localhost")
var DB_PORT = utils.GetEnv("DB_PORT", "25432")
var DB_DATABASE = utils.GetEnv("DB_DATABASE", "crosslink")
var ConnectionString = dbutil.GetConnectionString(DB_TYPE, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE)
var ConnectionStringSchema = "&search_path=crosslink_broker"
var API_PAGE_SIZE int32 = int32(utils.Must(utils.GetEnvInt("API_PAGE_SIZE", int(api.LIMIT_DEFAULT))))
var MigrationsFolder = "file://migrations"
var ENABLE_JSON_LOG = utils.GetEnv("ENABLE_JSON_LOG", "false")
Expand Down Expand Up @@ -265,7 +264,7 @@ func RunMigrateScripts() error {
}

func InitDbPool() (*pgxpool.Pool, error) {
dbPool, err := dbutil.InitDbPool(ConnectionString + ConnectionStringSchema)
dbPool, err := dbutil.InitDbPool(ConnectionString)
if err != nil {
return nil, fmt.Errorf("unable to create pool to database: %w", err)
}
Expand All @@ -279,7 +278,7 @@ func CreateEventRepo(dbPool *pgxpool.Pool) events.EventRepo {
}

func CreateEventBus(eventRepo events.EventRepo) events.EventBus {
eventBus := events.NewPostgresEventBus(eventRepo, ConnectionString+ConnectionStringSchema)
eventBus := events.NewPostgresEventBus(eventRepo, ConnectionString)
return eventBus
}

Expand Down
2 changes: 1 addition & 1 deletion broker/ill_db/illrepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMain(m *testing.M) {
ctx, pgc, connStr, err := test.StartPGContainer()
test.Expect(err, "failed to start db container")
pgIllRepo := new(PgIllRepo)
pgIllRepo.Pool, err = dbutil.InitDbPool(connStr + "&search_path=crosslink_broker")
pgIllRepo.Pool, err = dbutil.InitDbPool(connStr)
test.Expect(err, "failed to create ill repo")
defer pgIllRepo.Pool.Close()
_, _, _, err = dbutil.RunMigrateScripts("file://../migrations", connStr)
Expand Down
12 changes: 0 additions & 12 deletions broker/migrations/001_create_tables.up.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'crosslink_broker') THEN
CREATE ROLE crosslink_broker PASSWORD 'tenant' NOSUPERUSER NOCREATEDB INHERIT LOGIN;
END IF;
END
$$;

CREATE SCHEMA IF NOT EXISTS crosslink_broker AUTHORIZATION crosslink_broker;

SET search_path TO crosslink_broker;

CREATE TABLE peer
(
id VARCHAR PRIMARY KEY,
Expand Down
6 changes: 3 additions & 3 deletions broker/test/events/eventbus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestMain(m *testing.M) {
err = app.RunMigrateScripts()
test.Expect(err, "failed to run migrations")

dbPool, err := dbutil.InitDbPool(connStr + app.ConnectionStringSchema)
dbPool, err := dbutil.InitDbPool(connStr)
test.Expect(err, "failed to init db pool")

eventRepo = app.CreateEventRepo(dbPool)
Expand All @@ -73,7 +73,7 @@ func TestMultipleEventHandlers(t *testing.T) {
receivedAr := make([][]events.Event, noPools)
ctx := context.Background()
for i := 0; i < noPools; i++ {
dbPool, err := dbutil.InitDbPool(app.ConnectionString + app.ConnectionStringSchema)
dbPool, err := dbutil.InitDbPool(app.ConnectionString)
assert.NoError(t, err, "failed to init db pool")
defer dbPool.Close()

Expand Down Expand Up @@ -130,7 +130,7 @@ func TestBroadcastEventHandlers(t *testing.T) {
receivedAr := make([][]events.Event, noPools)
ctx := context.Background()
for i := 0; i < noPools; i++ {
dbPool, err := dbutil.InitDbPool(app.ConnectionString + app.ConnectionStringSchema)
dbPool, err := dbutil.InitDbPool(app.ConnectionString)
assert.NoError(t, err, "failed to init db pool")
defer dbPool.Close()

Expand Down
Loading