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

Improve readability with new lines #18

Open
dcrystalj opened this issue Oct 16, 2023 · 5 comments
Open

Improve readability with new lines #18

dcrystalj opened this issue Oct 16, 2023 · 5 comments

Comments

@dcrystalj
Copy link

My atlas.hcl

data "external_schema" "gorm" {
  program = [
    "go",
    "run",
    "./loader",
  ]
}

env "gorm" {
  src = data.external_schema.gorm.url
  dev = "docker://postgres/16/dev"
  migration {
    dir = "file://db/migrations"
    format = golang-migrate
  }
  format {
    migrate {
      diff = "{{ sql . \" \" }}"
    }
  }
}

Migrations created are quite unreadable. Is there a way to have new line in front of ADD column or ALTER COLUMN ?

@luantranminh
Copy link
Collaborator

@dcrystalj Could you please share what your migrations look like and what your desired state is?

@dcrystalj
Copy link
Author

Sorry I did not provide example.

The issue with readability is only with long lines being too long. Here are my real examples:

ALTER TABLE "public"."raw_activity" ADD COLUMN "order_plan" integer NOT NULL, ADD COLUMN "order_counter" integer NOT NULL, ADD COLUMN "finish_setup_date" timestamptz NULL, ADD COLUMN "finish_setup_time" timestamptz NULL;
CONSTRAINT "fk_salary_variable_log_salary_person" FOREIGN KEY ("salary_person_id") REFERENCES "public"."salary_person" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,

@luantranminh
Copy link
Collaborator

@dcrystalj Ah, you're right. It would be better if the formatter could produce something like:

ALTER TABLE "public"."raw_activity"
  ADD COLUMN "order_plan" INTEGER NOT NULL,
  ADD COLUMN "order_counter" INTEGER NOT NULL,
  ADD COLUMN "finish_setup_date" TIMESTAMPTZ NULL,
  ADD COLUMN "finish_setup_time" TIMESTAMPTZ NULL; 

instead of a long line of SQL. But sadly, there is no option for this formatting style at the moment. I'll let you know if an improvement on it is released.

@rotemtam
Copy link
Member

@luantranminh
Copy link
Collaborator

thanks @rotemtam , but it seems like a slightly different case. Intended sql works for CREATE TABLE but keep ALTER TABLE and CONSTRAINT in one line.

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

3 participants