Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude tables created by extensions #120

Merged
merged 5 commits into from
Apr 29, 2024
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
2 changes: 1 addition & 1 deletion lib/pg_easy_replicate/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def determine_tables(conn_string:, list: "", schema: nil)
if tables.size > 0
tables
else
list_all_tables(schema: schema, conn_string: conn_string)
list_all_tables(schema: schema, conn_string: conn_string) - %w[ spatial_ref_sys ]
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/database_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ def setup(connection_url, user = "james-bond")
index(:id)
end
end

unless conn.table_exists?("spatial_ref_sys")
conn.create_table("spatial_ref_sys") do
primary_key(:id)
column(:name, String)
column(:last_purchase_at, Time)
foreign_key(:seller_id, :sellers, on_delete: :cascade)
index(:seller_id)
index(:id)
end
end
ensure
conn&.disconnect
end
Expand Down
9 changes: 7 additions & 2 deletions spec/pg_easy_replicate/orchestrate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@
end

it "succesfully for all tables" do
tables = described_class.determine_tables(
schema: test_schema,
conn_string: connection_url,
)

described_class.add_tables_to_publication(
group_name: "cluster1",
schema: test_schema,
conn_string: connection_url,
tables: %w[items sellers],
tables: tables,
)

expect(pg_publication_tables(connection_url: connection_url)).to eq(
Expand Down Expand Up @@ -133,7 +138,7 @@
schema: test_schema,
conn_string: connection_url,
)
expect(r.sort).to eq(%w[items sellers])
expect(r.sort).to eq(%w[items sellers spatial_ref_sys])
end
end

Expand Down