-
Notifications
You must be signed in to change notification settings - Fork 73
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
Difficulties integrating into project #446
Comments
Thank you for opening this one @ericwooley! We recently discussed this, and this is a possible approach we could take:
I believe these 2 new commands would ease local development and continuous deployment. Please let us know what you think, we are really interested in your feedback!: |
Those sound like great improvements. I believe they would relieve the issues I'm running into. Thanks for getting back! Do you want me to leave the issue open? Looks like it's assigned and part of a milestone |
Yes, let's leave this issue open to add the |
Add a `pgroll migrate` subcommand. ## Documentation `pgroll migrate` applies all outstanding migrations from a source directory to the target database. Assuming that migrations up to and including migration `40_create_enum_type` from the [example migrations directory](https://github.com/xataio/pgroll/tree/main/examples) have been applied, running: ``` $ pgroll migrate examples/ ``` will apply migrations from `41_add_enum_column` onwards to the target database. If the `--complete` flag is passed to `pgroll migrate` the final migration to be applied will be completed. Otherwise the final migration will be left active (started but not completed). ## Notes: * If no migrations have yet been applied to the target database, `migrate` applies all of the migrations in the source directory. * This PR removes the `pgroll bootstrap` command (#414) as it is equivalent to running `pgroll migrate <directory> --complete` against a fresh database. Part of #446
Add a `pgroll latest` command to show the latest version in either the target database or a local directory of migration files. ## Documentation `pgroll latest` prints the latest schema version in either the target database or a local directory of migration files. By default, `pgroll latest` prints the latest version in the target database. Use the `--local` flag to print the latest version in a local directory of migration files instead. In both cases, the `--with-schema` flag can be used to prefix the latest version with the schema name. #### Database Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) have been applied to the `public` schema in the target database, running: ``` $ pgroll latest ``` will print the latest version in the target database: ``` 45_add_table_check_constraint ``` The exact output will vary as the `examples/` directory is updated. #### Local Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) are on disk in a directory called `examples`, running: ``` $ pgroll latest --local examples/ ``` will print the latest migration in the directory: ``` 45_add_table_check_constraint ``` The exact output will vary as the `examples/` directory is updated. --- Part of #446
Hey guys, quick question on this for @andrew-farries and @exekias. I want to integrate pgroll into my project, Given the migration sequence of If the latter, could I suggest a change in behaviour to the former if possible to keeping |
Hi @wtaylor 👋
In this case it will be
Multiple active migrations would allow us to accommodate the scenario you describe with |
@ericwooley we recently released v0.8 of It would good to hear how far these additions go towards solving your problems integrating |
@andrew-farries Tried out 0.8 last night, great set of QOL features! I'll gist it when I'm done, but I'm putting together a small python wrapper script to get the behaviour I'm looking for. The quick version is:
I couldn't find anything in the docs on operations specifically, am I right in assuming they're applied in sequential order? |
Yes, the operations in a migration are applied in the order in which they appear in the migration. Squashing multiple migrations into a single migration like this would be useful behaviour to build into In order for this to work reliably though we first need to address #239, which limits how useful multi-operation migrations are in practice. |
Yup, ran into #239 pretty quickly! 🥲 Anyhow, I created a wrapper script, I'm awful at Python but it seems to work if this is useful to anyone else: Gist The purpose of the script is to be deployed before the app code then:
The script is just lacking a The script will get a lot more useful when #239 get's a bit more finished. On the other hand, if the joining like behaviour of "keep the previous and latest schema versions available" get's added into |
Hello!
I love the project and the goal.
However, as it stands, it's pretty hard to integrate into a project with multiple branches and developers.
Presumably, each developer, working on different branches would have different migration files. Something like this
When they all get merged it's hard to know whats been merged, and in what order to run them.
i've resorted to scripting the creation of migrations so that they have time stamps, so they run in order of the time the developer created them, which seems to work ok, but then the migration script on pull down needs to figure out which migrations to run, and which ones not to run for this environment, and there doesn't seem to be a way to check that using the CLI. Currently I'm having to resort to querying the migrations table myself to see what needs to be run.
Another option i considered was storing individual operations in a folder, based on release, but this also gets hard to manage as different releases might happen with different features etc.... Which would require moving files around as part of the release process.
Guidance on this would be helpful, or possibly allowing a status query on individual migrations files, so that I can check if each migration has already been run, and skip it if so.
I'm using this for a typical SASS deployment process for now, so most of the time I will just be running
pgroll start <file> --complete
. But I like the idea of using this for gnarlier future migrations as well, when necessary.The text was updated successfully, but these errors were encountered: