Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"after" in migration configuration should use VCS history if VCS enabled#298

mplanchard started this conversation inIdeas
Discussion options

Right now, it seems like theafter configuration for migrations is closely coupled with a file format used by certain ORMs (e.g. prisma).

In our project, the files are named like0001_whatever.sql, with no timestamp.

Ifafter is going to refer to a timestamp rather than a migration number, it would be nice to do it in a more generalized way. The first thing that comes to mind is using git to determine the file's last modification time, if VCS integration is enabled.

Alternatively, a configuration option to use migration numbers would be nice, which could potentially take some kind of DSL to convert filenames to migration numbers (perhaps a sed command).

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

As it stands, we just use this make target, which works well enough:

# Only lint migrations after 172, since we can't change old ones, and# 172-forward lint without errors currently.LINTED_MIGRATIONS :=$(shell fd . 'data/db/proxy/migrations' \--extension sql \--max-depth 1 \--format {/} \--exec bash -c '[[ "{/}" > "0172" ]] && echo {}')# Lint db migrations. Note that the DB must be running for this check.db-lint: .make/db-lint.PHONY: db-lint.make/db-lint:$(LINTED_MIGRATIONS) | .makeif [["$?" ]];thenpostgrestools check$?fitouch .make/db-lint
You must be logged in to vote
0 replies
Comment options

Thanks for the feedback! Did you see this part in the docs?

For pre-commit hooks and when working locally, use --staged to only lint files that have been staged. In CI environments, you most likely want to use --changed to only lint files that have been changed compared to your vcs.defaultBranch configuration. If defaultBranch is not set in your postgrestools.jsonc, use --since=REF to specify the base branch to compare against.

Stil, I will test this on the weekend, because I am quite sure we don't care about timestamps and simply parse the number. So maybe there is just a bug here and your case should work.

You must be logged in to vote
2 replies
@psteinroe
Comment options

@mplanchard in the next release,after will work with numeric prefixes. So0001_whatever.sql will work.

@mplanchard
Comment options

That's great, thanks!

Re: the--staged option, I did see that, but we generally like to be able to run totally equivalent checks in our local environment and CI, without needing to worry about the state of the git repository or whatever, although using--staged for a precommit hook is definitely something we might do.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Ideas
Labels
None yet
2 participants
@mplanchard@psteinroe

[8]ページ先頭

©2009-2025 Movatter.jp