Skip to content

Commit 43717c8

Browse files
boilerplate
1 parent 18a7503 commit 43717c8

10 files changed

Lines changed: 450 additions & 13 deletions

File tree

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ PG_USER=postgres
2929
PG_PASSWORD=postgres
3030
PG_DATABASE=postgres
3131

32+
PG2_HOST=host.docker.internal
33+
PG2_PORT=5437
34+
PG2_USER=postgres
35+
PG2_PASSWORD=postgres
36+
PG2_DATABASE=postgres
37+
3238
PEERDB_CATALOG_HOST=host.docker.internal
3339
PEERDB_CATALOG_PORT=9901
3440
PEERDB_CATALOG_USER=postgres

Tiltfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ local_resource(
113113
resource_deps=['postgres']
114114
)
115115

116+
local_resource(
117+
'provision-postgres2',
118+
cmd='./local_provision_scripts/postgres.sh peerdb-postgres2',
119+
labels=['Ancillary-DB-Provisioning'],
120+
resource_deps=['postgres2']
121+
)
122+
116123
# This is not defined as a resource as we need the file to be present
117124
# when `docker_compose` loads the configuration (next line).
118125
local('./generate-test-environment.sh')
@@ -150,6 +157,10 @@ dc_resource('postgres', labels=['Ancillary-DB'], links=[
150157
link('http://localhost:5432', 'PostgreSQL'),
151158
], auto_init=False)
152159

160+
dc_resource('postgres2', labels=['Ancillary-DB'], links=[
161+
link('http://localhost:5437', 'PostgreSQL (secondary)'),
162+
], auto_init=False)
163+
153164
local_resource(
154165
'all-test-resources',
155166
cmd=' '.join([

ancillary-docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ services:
125125
timeout: 10s
126126
retries: 5
127127

128+
postgres2:
129+
container_name: peerdb-postgres2
130+
image: ${POSTGRES_IMAGE}
131+
restart: unless-stopped
132+
volumes:
133+
- postgres2_data:/var/lib/postgresql/data
134+
ports:
135+
- "${PG2_PORT}:5432"
136+
environment:
137+
PGUSER: ${PG2_USER}
138+
POSTGRES_PASSWORD: ${PG2_PASSWORD}
139+
POSTGRES_DB: ${PG2_DATABASE}
140+
POSTGRES_INITDB_ARGS: --locale=C.UTF-8
141+
extra_hosts:
142+
- "host.docker.internal:host-gateway"
143+
healthcheck:
144+
test: ["CMD", "pg_isready"]
145+
interval: 2s
146+
timeout: 10s
147+
retries: 5
148+
128149
dozzle:
129150
container_name: dozzle-compose-monitor
130151
image: amir20/dozzle:latest
@@ -185,6 +206,7 @@ services:
185206

186207
volumes:
187208
postgres_data:
209+
postgres2_data:
188210
clickhouse_data:
189211
mongo_data:
190212
mysql_gtid_data:

flow/activities/flowable.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,10 @@ func (a *FlowableActivity) MigratePostgresTableOIDs(
21442144
return nil
21452145
}
21462146

2147+
func (a *FlowableActivity) PeerDBPGAutomatedSchemaDump(ctx context.Context, env map[string]string) (bool, error) {
2148+
return internal.PeerDBPGAutomatedSchemaDump(ctx, env)
2149+
}
2150+
21472151
func (a *FlowableActivity) RunPgDumpSchema(
21482152
ctx context.Context,
21492153
input *protos.RunPgDumpSchemaInput,

flow/connectors/postgres/validate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ func (c *PostgresConnector) ValidateMirrorDestination(
278278
return nil // no need to validate schema for resync, as we will create or replace the tables
279279
}
280280

281+
if cfg.System == protos.TypeSystem_PG && cfg.Env["PEERDB_PG_AUTOMATED_SCHEMA_DUMP"] == "true" {
282+
return nil // pg_dump will create the schema and tables on the destination
283+
}
284+
281285
// Validate that all source columns exist in destination tables
282286
checkedSchemas := make(map[string]struct{})
283287
for _, tableMapping := range cfg.TableMappings {

0 commit comments

Comments
 (0)