-
Notifications
You must be signed in to change notification settings - Fork 106
[baseline] Make start
and migrate
fail on non-empty schema without migration histories
#835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[baseline] Make start
and migrate
fail on non-empty schema without migration histories
#835
Conversation
start
and migrate
fail on non-empty schema without migration historiesstart
and migrate
fail on non-empty schema without migration histories
@andrew-farries could not we run |
We could automatically run the baseline, but we'd have to prompt the user for a baseline version name as the It feels more like this is a scenario where the user should be in control of the baseline rather than making it happen automatically. |
Having it happen after a prompt sounds good to me! |
Yes, absolutely. We could make the user aware, and give them the option to add a version name. I think it would still be an improvement if we let the baseline process start and once that's complete, prompted with complete, a bit more hand-holding at that stage too. |
The CTA to run Not sure about prompting the user directly in
|
Good point, we would not want to break CI/CD processes of our users. I am okay with "Run |
808912d
to
6d26c92
Compare
06fb647
to
f574366
Compare
The method checks whether the given schema is non-empty with an empty history.
Allow tests to work with an uninitialized state and provide connection info so that the test can initialize `pgroll` at some later point.
Ensure that starting a migration on a schema with existing tables but no migration history fails with the expected error.
Make `Roll.Start` return an error when a caller tries to start a migration when there is existing schema and no migration history.
Make the `start` and `migrate` commands check whether a baseline is needed and exit early if so.
6d26c92
to
6adfba2
Compare
Make the
pgroll start
andpgroll migrate
commands fail when run against a non-empty schema without a migration history. The error message suggests runningpgroll baseline
before re-runningstart
ormigrate
.Running an initial migration against a non-empty schema is not recommended becauses it can result in a migration that can't be rolled back if the migration references pre-existing objects in the schema.
The recommended workflow is:
migrate
as usualThis ensures that the full schema is brought into
pgroll
before running the first migration.Part of #364