Skip to content

Conversation

@stephane-klein
Copy link
Contributor

@stephane-klein stephane-klein commented Mar 28, 2021

Following this comment, this is a new Pull Request.

By default, gomigrate quote migrations table name, if x-migrations-table-quoted is enabled, then you must to quote migrations table name manually, for instance "gomigrate"."schema_migrations".

I have used this playground to test this branch.

@stephane-klein
Copy link
Contributor Author

@dhui what do you think about this implementation?

@stephane-klein stephane-klein changed the title WIP: Postgres - add x-migrations-table-quoted url query option (#95) Postgres - add x-migrations-table-quoted url query option (#95) Mar 29, 2021
@FAQinghere
Copy link

I’m probably just confused, but in ensureVersionTable(), line 454, why does it not respect the config setting for the schema when it’s verifying whether or not the table exists already?

	query := `SELECT COUNT(1) FROM information_schema.tables WHERE table_name = $1 AND table_schema = (SELECT current_schema()) LIMIT 1`

@stephane-klein
Copy link
Contributor Author

I’m probably just confused, but in ensureVersionTable(), line 454, why does it not respect the config setting for the schema when it’s verifying whether or not the table exists already?

Ok, it is a new code: spacefill@511ae9f

I'm going to fix this part 👍

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from ac69c0f to 525c478 Compare April 4, 2021 09:07
@stephane-klein
Copy link
Contributor Author

stephane-klein commented Apr 4, 2021

I’m probably just confused, but in ensureVersionTable(), line 454, why does it not respect the config setting for the schema when it’s verifying whether or not the table exists already?

@FAQinghere @dhui implemented in my last push.

I think that the next task is to implement the same feature for database/pgx/ version, isn't it?

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from 525c478 to f98a02e Compare April 4, 2021 10:51
@stephane-klein
Copy link
Contributor Author

I don't understand this golangci-lint error:

$ golangci-lint run
database/postgres/postgres.go:44:13: struct of size 80 bytes could be of size 72 bytes (maligned)
type Config struct {
            ^

Exited with code exit status 1

The code is here

type Config struct {
	MigrationsTable       string
	MigrationsTableQuoted bool
	DatabaseName          string
	SchemaName            string
	StatementTimeout      time.Duration
	MultiStatementEnabled bool
	MultiStatementMaxSize int
}

I don't understand where is my error🤔

@FAQinghere
Copy link

FAQinghere commented Apr 4, 2021

Words are 4 or 8 bytes long (32-bit vs 64-bit systems), and fields in structs are probably word-aligned. If a bool only needs one byte, and is followed by something else that doesn’t fit within the same word, then the rest of the word will be padded out (skipped), bloating the struct. Maybe move the bools to the end.

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from f98a02e to 6890aa5 Compare April 4, 2021 12:00
@coveralls
Copy link

coveralls commented Apr 4, 2021

Pull Request Test Coverage Report for Build 292

  • 77 of 81 (95.06%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 57.241%

Changes Missing Coverage Covered Lines Changed/Added Lines %
database/pgx/pgx.go 38 40 95.0%
database/postgres/postgres.go 39 41 95.12%
Totals Coverage Status
Change from base Build 274: 0.4%
Covered Lines: 3502
Relevant Lines: 6118

💛 - Coveralls

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch 2 times, most recently from cf2fbf4 to f31e3b5 Compare April 4, 2021 19:08
@stephane-klein
Copy link
Contributor Author

I think that the next task is to implement the same feature for database/pgx/ version, isn't it?

database/pgx/ implementation done.

@dhui I think that you can review.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Thanks for updating both the postgres and pgx drivers! Don't forget to apply any changes to both the pgx and postgres drivers.

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from f31e3b5 to 4ff1792 Compare April 10, 2021 14:20
@stephane-klein
Copy link
Contributor Author

@dhui all you feedbacks had been applied.

New need review 😉

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from 4ff1792 to d695432 Compare April 10, 2021 14:23
@stephane-klein stephane-klein requested a review from dhui April 11, 2021 21:03
Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the PR feedback!

@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from d695432 to 63ed3da Compare April 18, 2021 12:55
…postgres and pgx drivers (golang-migrate#95)

By default, gomigrate quote migrations table name, if `x-migrations-table-quoted` is enabled, then you must to quote migrations table name manually, for instance `"gomigrate"."schema_migrations"`
@stephane-klein stephane-klein force-pushed the 95-x-migrations-table-quoted branch from 63ed3da to fcf19a1 Compare April 18, 2021 19:30
@stephane-klein
Copy link
Contributor Author

New need review 😉 (see this comment)

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the PR feedback!

For future changes, can you push your changes as a new commit on top of the latest PR commit? If you need to force push to re-run tests, just amend the latest commit. This makes it easier for me to review so I don't need to review the whole PR again. If there are a lot of commits, I'll squash-merge the PR.

@stephane-klein
Copy link
Contributor Author

For future changes, can you push your changes as a new commit on top of the latest PR commit?

Ok 👍

@dhui New commit with fix is here: 37af6dd

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for going through the multiple rounds of feedback!

@dhui dhui merged commit 3d5d577 into golang-migrate:master Apr 19, 2021
@stephane-klein
Copy link
Contributor Author

@dhui thanks 🙂

nitpick: last commit message Work in progress has not been removed throughout the squash-merge :

* Postgres and pgx - Add x-migrations-table-quoted url query option to postgres and pgx drivers (#95)

By default, gomigrate quote migrations table name, if `x-migrations-table-quoted` is enabled, then you must to quote migrations table name manually, for instance `"gomigrate"."schema_migrations"`

* Work In Progress

@dhui
Copy link
Member

dhui commented Apr 20, 2021

With Github's squash-merge, the commit messages are combined into the squashed commit's message.

@stephane-klein
Copy link
Contributor Author

With Github's squash-merge, the commit messages are combined into the squashed commit's message.

Yes I know, but it was a "work in progress" commit message.

That why I like to squash + push --force to avoid to push accidentally this "bad" commit message to master branch.

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.

4 participants