Skip to content

pgroll convert generates invalid pgroll migration if comments in SQL #719

@richardgill

Description

@richardgill
❯ cat ./drizzle/example.sql

CREATE TABLE IF NOT EXISTS "dogs" (
        "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "dogs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
        "name" varchar(255) NOT NULL,
        "age" integer NOT NULL
);
-- comment
CREATE INDEX IF NOT EXISTS "name" ON "dogs" USING btree ("name");
❯ pgroll convert ./drizzle/example.sql
{
  "name": "20250313162406",
  "operations": [
    {
      "sql": {
        "up": "CREATE TABLE IF NOT EXISTS \"dogs\" (\n\t\"id\" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name \"dogs_id_seq\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),\n\t\"name\" varchar(255) NOT NULL,\n\t\"age\" integer NOT NULL\n)"
      }
    },
    {
      "sql": {
        "up": "-- comment\nCREATE INDEX IF NOT EXISTS \"name\" ON \"dogs\" USING btree (\"name\")"
      }
    }
  ]
}


Drizzle leaves comments in it's generated SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions