Merge pull request #10993 from Budibase/budi-7115-install_pgdump
BUDI-7115 - Install pgdump
This commit is contained in:
commit
1a46879c90
|
@ -37,6 +37,14 @@ COPY --from=build /worker /worker
|
|||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends software-properties-common nginx uuid-runtime redis-server
|
||||
|
||||
# Install postgres client for pg_dump utils
|
||||
RUN apt install software-properties-common apt-transport-https gpg -y \
|
||||
&& curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null \
|
||||
&& echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | tee /etc/apt/sources.list.d/postgresql.list \
|
||||
&& apt update -y \
|
||||
&& apt install postgresql-client-15 -y \
|
||||
&& apt remove software-properties-common apt-transport-https gpg -y
|
||||
|
||||
# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
|
||||
WORKDIR /nodejs
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh && \
|
||||
|
|
|
@ -26,11 +26,21 @@ RUN apt-get install unzip libaio1
|
|||
COPY scripts/integrations/oracle/ scripts/integrations/oracle/
|
||||
RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
|
||||
|
||||
# Install postgres client for pg_dump utils
|
||||
RUN apt update && apt upgrade -y \
|
||||
&& apt install software-properties-common apt-transport-https curl gpg -y \
|
||||
&& curl -fsSl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null \
|
||||
&& echo deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main | tee /etc/apt/sources.list.d/postgresql.list \
|
||||
&& apt update -y \
|
||||
&& apt install postgresql-client-15 -y \
|
||||
&& apt remove software-properties-common apt-transport-https curl gpg -y
|
||||
|
||||
|
||||
COPY package.json .
|
||||
COPY dist/yarn.lock .
|
||||
RUN yarn install --production=true
|
||||
# Remove unneeded data from file system to reduce image size
|
||||
RUN yarn cache clean && apt-get remove -y --purge --auto-remove g++ make python \
|
||||
RUN yarn install --production=true \
|
||||
# Remove unneeded data from file system to reduce image size
|
||||
&& yarn cache clean && apt-get remove -y --purge --auto-remove g++ make python \
|
||||
&& rm -rf /tmp/* /root/.node-gyp /usr/local/lib/node_modules/npm/node_modules/node-gyp
|
||||
|
||||
COPY dist/ dist/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,18 +5,26 @@ jest.unmock("pg")
|
|||
|
||||
describe("getExternalSchema", () => {
|
||||
describe("postgres", () => {
|
||||
let host: string
|
||||
let port: number
|
||||
let config: any
|
||||
|
||||
// Remove versioning from the outputs to prevent failures when running different pg_dump versions
|
||||
function stripResultsVersions(sql: string) {
|
||||
const result = sql
|
||||
.replace(/\n[^\n]+Dumped from database version[^\n]+\n/, "")
|
||||
.replace(/\n[^\n]+Dumped by pg_dump version[^\n]+\n/, "")
|
||||
.toString()
|
||||
return result
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
// This is left on propose without a tag, so if a new version introduces a breaking change we will be notified
|
||||
const container = await new GenericContainer("postgres")
|
||||
.withExposedPorts(5432)
|
||||
.withEnv("POSTGRES_PASSWORD", "password")
|
||||
.start()
|
||||
|
||||
host = container.getContainerIpAddress()
|
||||
port = container.getMappedPort(5432)
|
||||
const host = container.getContainerIpAddress()
|
||||
const port = container.getMappedPort(5432)
|
||||
|
||||
config = {
|
||||
host,
|
||||
|
@ -33,14 +41,11 @@ describe("getExternalSchema", () => {
|
|||
it("can export an empty database", async () => {
|
||||
const integration = new postgres.integration(config)
|
||||
const result = await integration.getExternalSchema()
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
|
||||
expect(stripResultsVersions(result)).toMatchInlineSnapshot(`
|
||||
"--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
|
||||
-- Dumped by pg_dump version 15.3
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
|
@ -63,31 +68,32 @@ describe("getExternalSchema", () => {
|
|||
it("can export a database with tables", async () => {
|
||||
const integration = new postgres.integration(config)
|
||||
|
||||
await integration.internalQuery({
|
||||
sql: `
|
||||
CREATE TABLE "users" (
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"role" VARCHAR(15) NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
CREATE TABLE "products" (
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"price" DECIMAL NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`,
|
||||
})
|
||||
await integration.internalQuery(
|
||||
{
|
||||
sql: `
|
||||
CREATE TABLE "users" (
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"role" VARCHAR(15) NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
CREATE TABLE "products" (
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"price" DECIMAL NOT NULL,
|
||||
"owner" INTEGER NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
ALTER TABLE "products" ADD CONSTRAINT "fk_owner" FOREIGN KEY ("owner") REFERENCES "users" ("id");`,
|
||||
},
|
||||
false
|
||||
)
|
||||
|
||||
const result = await integration.getExternalSchema()
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
expect(stripResultsVersions(result)).toMatchInlineSnapshot(`
|
||||
"--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
|
||||
-- Dumped by pg_dump version 15.3
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
|
@ -110,7 +116,8 @@ describe("getExternalSchema", () => {
|
|||
CREATE TABLE public.products (
|
||||
id integer NOT NULL,
|
||||
name character varying(100) NOT NULL,
|
||||
price numeric NOT NULL
|
||||
price numeric NOT NULL,
|
||||
owner integer
|
||||
);
|
||||
|
||||
|
||||
|
@ -203,6 +210,14 @@ describe("getExternalSchema", () => {
|
|||
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: products fk_owner; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.products
|
||||
ADD CONSTRAINT fk_owner FOREIGN KEY (owner) REFERENCES public.users(id);
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
@ -214,20 +229,19 @@ describe("getExternalSchema", () => {
|
|||
it("does not export a data", async () => {
|
||||
const integration = new postgres.integration(config)
|
||||
|
||||
await integration.internalQuery({
|
||||
sql: `INSERT INTO "users" ("name", "role") VALUES ('John Doe', 'Administrator');
|
||||
await integration.internalQuery(
|
||||
{
|
||||
sql: `INSERT INTO "users" ("name", "role") VALUES ('John Doe', 'Administrator');
|
||||
INSERT INTO "products" ("name", "price") VALUES ('Book', 7.68);`,
|
||||
})
|
||||
},
|
||||
false
|
||||
)
|
||||
|
||||
const result = await integration.getExternalSchema()
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
expect(stripResultsVersions(result)).toMatchInlineSnapshot(`
|
||||
"--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
|
||||
-- Dumped by pg_dump version 15.3
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
|
@ -250,7 +264,8 @@ describe("getExternalSchema", () => {
|
|||
CREATE TABLE public.products (
|
||||
id integer NOT NULL,
|
||||
name character varying(100) NOT NULL,
|
||||
price numeric NOT NULL
|
||||
price numeric NOT NULL,
|
||||
owner integer
|
||||
);
|
||||
|
||||
|
||||
|
@ -343,6 +358,14 @@ describe("getExternalSchema", () => {
|
|||
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: products fk_owner; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.products
|
||||
ADD CONSTRAINT fk_owner FOREIGN KEY (owner) REFERENCES public.users(id);
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
|
2059
qa-core/yarn.lock
2059
qa-core/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue