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

Removed pg_dump usage in postgres in favor of normal SQL queries #125

Merged
merged 4 commits into from
Jun 23, 2024

Conversation

emilpriver
Copy link
Owner

@emilpriver emilpriver commented Jun 23, 2024

This PR removes the usage of pg_dump and replaces it with normal sql queries.

This code generates something like this:

--
-- SQL Schema dump automatic generated by geni
--


-- EXTENSIONS

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;

-- TABLES
-- EXTENSIONS

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;

-- TABLES

CREATE TABLE schema_migrations (
 id character varying (255) NOT NULL
);

CREATE TABLE table_1 (
 name character varying (255) NOT NULL
);

CREATE TABLE table_2 (
 id integer  NOT NULL,
 name character varying (255) NOT NULL,
 created_at timestamp without time zone
);

-- VIEWS

CREATE VIEW brazil AS\n SELECT table_2.name
   FROM table_2
  WHERE (table_2.id = 2);;

-- CONSTRAINTS

ALTER TABLE schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (id);

ALTER TABLE table_2 ADD CONSTRAINT employee_unq UNIQUE (name);

ALTER TABLE table_2 ADD CONSTRAINT table_2_pkey PRIMARY KEY (id);

-- INDEXES

CREATE UNIQUE INDEX employee_unq ON public.table_2 USING btree (name)

CREATE UNIQUE INDEX schema_migrations_pkey ON public.schema_migrations USING btree (id)

CREATE UNIQUE INDEX table_2_pkey ON public.table_2 USING btree (id)

-- COMMENTS

COMMENT ON COLUMN table_2.id IS comment text;

Closes #33

@emilpriver emilpriver self-assigned this Jun 23, 2024
@emilpriver emilpriver merged commit d8ab499 into main Jun 23, 2024
19 checks passed
@emilpriver emilpriver deleted the pg-dump branch June 23, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postgres:use sql queries for dumping database structure
1 participant