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

Postgres create table script should combine primary key lines into create table query #9

Open
MasterOdin opened this issue Nov 11, 2020 · 0 comments

Comments

@MasterOdin
Copy link
Member

For the create table script for postgres, for a table with a primary key it generates two queries: (1) the overall create table query and (2) the create primary key constraint on the table.

This is done somewhat for simplicity's sake in getting things to work as expected under postgres 8, but it creates a worse user experience for it compared to the other database adapters which just generate one query. As such, the postgres create table script function should be reworked so that it outputs one query again while still being postgres 8 (and redshift) compatible. Accomplishing this should be fairly easily doable by instead of appending ALTER TABLE statements, instead append the table constraints to the create table script after the column definitions. For example, take:

CREATE TABLE foo (
  id INT NOT NULL,
);

ALTER TABLE foo ADD CONSTRAINT foo_pk PRIMARY KEY (id);

and adjust it so that it instead does:

CREATE TABLE foo (
  id INT NOT NULL,
  PRIMARY KEY (id),
);
@MasterOdin MasterOdin transferred this issue from sqlectron/sqlectron-core Feb 17, 2021
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

No branches or pull requests

1 participant