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

Ability to run both SQL and RS migrations #170

Merged
merged 10 commits into from
Sep 5, 2021
Merged

Conversation

omid
Copy link
Contributor

@omid omid commented Aug 30, 2021

Fixes #154

@omid omid marked this pull request as ready for review August 30, 2021 18:01
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! And thanks for this amazing work! ❤️ left some comments, if you feel changing the tests structure to address the new changes takes too much time no worries, we can do it in subsequent PR's :)

@@ -0,0 +1,2 @@
ALTER TABLE cars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the addition of this sql migration on the mod migrations dir on purpose? i.e. to test a dir with both sql and mod migrations, I think since we are now merging the macro do embed migrations it probably makes sense to change the tests to work with both, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it on purpose, to test both sql and mod. Also agree tests need a revisit!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok yeah so since the tests are passing and work, we can do it on a subsequent PR if you feel like doing it, and we can merge this one before

@@ -18,41 +16,46 @@ mod mysql {

mod embedded {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embedded used to be the .sql migrations but since now everything is embedded this relates with my question above that it probably makes sense to update the tests

examples/modules/migrations/mod.rs Show resolved Hide resolved
refinery_macros/src/lib.rs Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@omid
Copy link
Contributor Author

omid commented Sep 2, 2021

Thanks. I agree. There are several tests to test SQL and RS. I'm sure we can merge (remove) some of them. It was hard for me to do this, since I'm kinda new to the source code.

@omid
Copy link
Contributor Author

omid commented Sep 3, 2021

The issue in GH Actions is related to another package.
Why do we run cargo rustdoc with nightly @jxs?

@jxs
Copy link
Member

jxs commented Sep 3, 2021

The issue in GH Actions is related to another package.
Why do we run cargo rustdoc with nightly @jxs?

it was needed because of broken_intra_doc_links but probably isn't required anymore.
Sorry I haven't yet replied to the question regarding include_bytes I will do so today still

@omid
Copy link
Contributor Author

omid commented Sep 3, 2021

@jxs thanks. Checked that. It's not needed to be on nightly anymore. So removed it in this PR.

refinery_macros/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now! thanks!! 🎆

@jxs jxs merged commit 5de8d03 into rust-db:main Sep 5, 2021
@omid omid deleted the merge_macros branch September 5, 2021 16:26
@omid
Copy link
Contributor Author

omid commented Sep 13, 2021

@jxs I don't like what I have done here :(
It's almost impossible to debug the RS migrations or use auto-completion or any kind of validation before running the code.

“Migration” can be anything, not even SQL. For example, I may want to use refinery to copy files from s3 to blob storage!
Currently, there is no way to set up the required libraries, or have auto-completion or …

Any idea how can we solve it? (I'm trying myself to solve it, may come back with some ideas :/ )

@jxs
Copy link
Member

jxs commented Sep 14, 2021

Hi, wdym debug? I can understand the auto-completion issues, but those are tooling related. If there's a way to improve them i am all for that, but I don't think that it should block these changes

“Migration” can be anything, not even SQL. For example, I may want to use refinery to copy files from s3 to blob storage!

yeah, but that also happened with mod migrations, you can do whatever you want inside the migration function.

Any idea how can we solve it? (I'm trying myself to solve it, may come back with some ideas :/ )

I can also think about an idea to make it so that when you edit these files rust-analyzer is able to find them in the path

@omid
Copy link
Contributor Author

omid commented Sep 14, 2021

By debug I mean, to be able to find the problems in the code while writing it. Before running migration.

yeah, but that also happened with mod migrations, you can do whatever you want inside the migration function.

Yes, but in this case, I need to define s3 and blob storage requirements in Cargo.toml.
So the requirements will be in Cargo.toml, but there might be no usage in any code, except the migrations that are not in src.

I can also think about an idea to make it so that when you edit these files rust-analyzer is able to find them in the path

That would be awesome.

@jxs
Copy link
Member

jxs commented Sep 14, 2021

By debug I mean, to be able to find the problems in the code while writing it. Before running migration.

but how is this different from previous mod_migrations! ?

Yes, but in this case, I need to define s3 and blob storage requirements in Cargo.toml.
So the requirements will be in Cargo.toml, but there might be no usage in any code, except the migrations that are not in src.

and the compiler/clippy complains about that?

@omid
Copy link
Contributor Author

omid commented Sep 14, 2021

but how is this different from previous mod_migrations! ?

Oh, it isn't? So I'm fine with this PR then :) Seems like another topic then

and the compiler/clippy complains about that?

I still don't know. Shouldn't be the case.

@jxs
Copy link
Member

jxs commented Sep 14, 2021

Oh, it isn't? So I'm fine with this PR then :) Seems like another topic then

I don't know ehe, so far the only downside from introducing this PR seems to be that auto-completion no longer works on the migration files right? Tbh I think that's a minor issue, which can be addressed later

I still don't know. Shouldn't be the case.

aha then it isn't a problem right?

@omid
Copy link
Contributor Author

omid commented Sep 14, 2021

OK, so all good 👍🏼

jxs added a commit to jxs/refinery that referenced this pull request Sep 17, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit to jxs/refinery that referenced this pull request Sep 18, 2021
and use it on `find_migration_files` to fix the bug introduced on rust-db#170 where refinery_cli tries to embed all
kinds of files not only .sql
jxs added a commit that referenced this pull request Sep 18, 2021
* refinery_cli: re-introduce MigrationType:

and use it on `find_migration_files` to fix the bug introduced on #170 where refinery_cli tries to embed all
kinds of files not only .sql

* tests: update test suite to match new merged macros:

remove redundant tests, closes #171

* ci: update rust stable version

* ci: use github barrel fork to address TLS issues,

while a proper version with SqlServer support isn't released
@jxs jxs mentioned this pull request Oct 2, 2021
@elbart
Copy link

elbart commented Oct 12, 2021

Hey! I am using refinery and just found out, that this PR is not yet in some publicly released crates.io version. @jxs are you planning to release that soon or is it possible to directly depend on the github crate?

@jxs
Copy link
Member

jxs commented Oct 15, 2021

Hi! Yeah I'll try to cut a release today with all the new changes :)
Thanks for your interest!

@jxs
Copy link
Member

jxs commented Oct 16, 2021

0.7.0 released :)

@elbart
Copy link

elbart commented Oct 16, 2021

@jxs awesome, thank you so much for all your work!

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.

Feature request: abiliy to use both .sql and .rs migrations
3 participants