Skip to content
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

Prepare omigrate for new driver #2

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

maiste
Copy link
Collaborator

@maiste maiste commented Oct 10, 2022

Hi!
This PR modifies the code interface to enable omigrate' to work with other DBSM`. The three main enhancements are:

  • It makes port, user and password optional. For the postgres version, the default value is kept as there was in the command line to maintain compatibility. This is not breaking any change.
  • It moves the Connection in Driver as they are related.
  • Move the parse_uri function inside the Driver.S signature, as the parsing might not fail on the same parsing error.

(This is a prequel for #3)

@maiste maiste mentioned this pull request Oct 10, 2022
@tmattio
Copy link
Owner

tmattio commented Oct 10, 2022

Thanks a lot @maiste! 🎉

Everything looks good to me, apart from the parse_uri part: I don't understand why it's needed to move it to the driver? Can you expand a little bit on this?

@maiste
Copy link
Collaborator Author

maiste commented Oct 11, 2022

Thanks for your help with it 😉

About the parse_uri, the issue is mainly this part of the function:

match Uri.path uri with
      | "/" -> Error (Omigrate_error.bad_uri s)
      | path ->
          if Filename.dirname path <> "/" then Error (Omigrate_error.bad_uri s)
          else Ok (Filename.basename path)

We want to check this for the PostgreSQL driver but not for the sqlite3 driver, for which the check is different. I think the check would be different for another database system (NoSQL one, for example).

@tmattio tmattio merged commit 67bed48 into tmattio:master Oct 11, 2022
@tmattio
Copy link
Owner

tmattio commented Oct 11, 2022

Thanks!

@maiste maiste deleted the prepare-new-driver branch October 11, 2022 07:53
tmattio added a commit to tmattio/opam-repository that referenced this pull request Oct 11, 2022
CHANGES:

- Support partial migrations (tmattio/omigrate#4, @maiste)
- New Sqlite3 driver (tmattio/omigrate#3, @maiste)
- Support optional auth with psql driver (tmattio/omigrate#2, @maiste)
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.

None yet

2 participants