Skip to content

Conversation

@bplunkett-stripe
Copy link
Collaborator

@bplunkett-stripe bplunkett-stripe commented Sep 4, 2024

Description

Support nested directories, i.e., walk nested directories

Motivation

Fixes #155
Relates to #162

Testing

Validated on schema dir with nested folders:

  |-foobar.sql
  |-last
  |  |-nested
  |  |  |-fk.sql
  |-earlier_schema
  |  |-enum.sql

Execution order should be lexical order of file paths.

 go run ./cmd/pg-schema-diff plan --schema-dir ~/stripe/tempschema --dsn 'host=localhost user=bplunkett dbname=postgres'           INT х │ 00:37:34

################################ Generated plan ################################
1. CREATE TYPE "public"."mood" AS ENUM ('sad', 'ok', 'happy');
        -- Statement Timeout: 3s

2. CREATE TABLE "public"."fk" (
        "id" text COLLATE "pg_catalog"."default"
);
        -- Statement Timeout: 3s

3. ALTER TABLE "public"."foobar" ADD COLUMN "id" character varying(255) COLLATE "pg_catalog"."default";
        -- Statement Timeout: 3s

4. ALTER TABLE "public"."foobar" ADD COLUMN "mood" mood;
        -- Statement Timeout: 3s

5. CREATE UNIQUE INDEX CONCURRENTLY foobar_id_key ON public.foobar USING btree (id);
        -- Statement Timeout: 20m0s
        -- Lock Timeout: 3s
        -- Hazard INDEX_BUILD: This might affect database performance. Concurrent index builds require a non-trivial amount of CPU, potentially affecting database performance. They also can take a while but do not lock out writes.

6. ALTER TABLE "public"."foobar" ADD CONSTRAINT "foobar_id_key" UNIQUE USING INDEX "foobar_id_key";
        -- Statement Timeout: 3s

7. ALTER TABLE "public"."fk" ADD CONSTRAINT "fk_id_fkey" FOREIGN KEY (id) REFERENCES foobar(id) NOT VALID;
        -- Statement Timeout: 3s

8. ALTER TABLE "public"."fk" VALIDATE CONSTRAINT "fk_id_fkey";
        -- Statement Timeout: 3s

//
// All records are scanned. If a duplicate key is found, an error is returned.
func LogFmtToMap(logFmt string) (map[string]string, error) {
func logFmtToMap(logFmt string) (map[string]string, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexport this

@bplunkett-stripe bplunkett-stripe merged commit 6937348 into main Sep 4, 2024
@bplunkett-stripe bplunkett-stripe deleted the bplunkett/support-nested-sql-dirs branch September 9, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support nested directories

3 participants