How can I check if versioned migrations are up to date with the schema? #2636
-
I have an old Python app which uses Peewee ORM for database acccess. I figured out how to configure it to produce migration files with a simple Here's my config: data "external_schema" "peewee" {
program = [
"helpers/db_schema.sh"
]
}
env "local" {
src = data.external_schema.peewee.url
dev = "sqlite://dev?mode=memory"
url = "sqlite://db.sqlite"
migration {
dir = "file://migrations"
}
format {
migrate {
diff = format("{{ sql . \" \" }}")
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@LiquidLemon you can run If somebody forgot to run |
Beta Was this translation helpful? Give feedback.
-
Note, you can also use atlas schema diff \
--from "file://migrations" \
--to env://orm \
--env local \
--format '{{ if .Changes }}fail{{ end }}' | grep '.' && exit 1 (Or, you can convert it to See the doc for more info: https://atlasgo.io/declarative/diff#compare-external-schemas |
Beta Was this translation helpful? Give feedback.
Note, you can also use
schema diff
(with custom--format
) for this and fail if there are changes:(Or, you can convert it to
if [ -n "$output" ]; then .. fi
).See the doc for more info: https://atlasgo.io/declarative/diff#compare-external-schemas