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

Implement extra status column in version table #196

Merged
merged 16 commits into from
Aug 27, 2022

Conversation

DjKillerMemeStar
Copy link
Contributor

No description provided.

Jari Flederick added 2 commits May 31, 2022 00:15
@DjKillerMemeStar
Copy link
Contributor Author

Automatic tests are done, still need to test locally.

Any ideas on how to avoid breaking current grate implementations are welcome!

@wokket
Copy link
Collaborator

wokket commented May 31, 2022

I've just had a quick look and this PR looks really good for first timer 👍

Any ideas on how to avoid breaking current grate implementations are welcome!

That's definitely a concern here, can you take a leaf out of the pattern we use at runtime and apply the new column only if it's needed? ie:

  • Leave the existing Sql in CreateVersionTable() alone,
  • Apply the new Status column via a second step only if needed (and make it nullable)

@DjKillerMemeStar
Copy link
Contributor Author

Thank you!

I thought about getting the list of columns from the version table and adding it if needed, however i wanted to avoid querying this all the time as we should avoid database trips that don't provide anything.

Do we have a way of flagging a step as "Done" for further runs? So it would only run the "Check status column in version table" sql the first time it runs with the new version?

@DjKillerMemeStar
Copy link
Contributor Author

DjKillerMemeStar commented Jun 1, 2022

Struggling a bit with the testing of the feature for all supported databases, but still wanted to show the progress I've made.

Not sure if i like how i did it here, i have a feeling it's to complex for just a simple column, but feel free to chime in!

@wokket
Copy link
Collaborator

wokket commented Jun 2, 2022

I've been pretty busy and haven't had a chance to look at this, but:

i wanted to avoid querying this all the time as we should avoid database trips that don't provide anything.

I wouldn't stress too much about this. While it's laudable (and we never want to be too inefficient) we are a database migration tool, it's expected that we're going run a lot of queries against the server.

Do we have a way of flagging a step as "Done" for further runs?

You could write it to the Version or ScriptsRun table 🤣

@erikbra
Copy link
Owner

erikbra commented Jun 5, 2022

Thanks a lot for this effort, @DjKillerMemeStar !

I think this is where we see a small deficiency in grate compared to RoundhousE, where we have our roots from. RoundhousE used NHibernate for the data migration tables, which I thought was a bit of an overkill, but this particular feature would definitely be easier to implement using a tool that specifically handles table versioning out-of-the-box.

I'm not keen on re-introducing the dependency on NHibernate, as it seems a bit of a huge dependency, so we need to handle this in some other way.

Some kind of "schema version" on the grate tables could be one solution, but we would of course handle existing databases, both with old and new "schema versions".

Could you please explain a bit about what you need the "Status" column for? What is your particular use case?

@DjKillerMemeStar
Copy link
Contributor Author

Hi @erikbra

Me personally i don't have a use case for the "Status" column, i do however see a use in having it. For example to know what migration (version) went wrong.

The main reason i wanted to do this is because i'm interested in supporting grate and solving this issue #112.

I agree with your NHibernate point, it's a bit much just for table versions.

@DjKillerMemeStar
Copy link
Contributor Author

I had to take a step back, because i was making it a bit to difficult for myself but i found a nice solution and i like how the code is written!

I just need to test it locally and then we are done!

@DjKillerMemeStar DjKillerMemeStar marked this pull request as ready for review June 6, 2022 22:36
@DjKillerMemeStar
Copy link
Contributor Author

image

Validated locally on an version without status column and it gets added correctly!

@wokket
Copy link
Collaborator

wokket commented Jun 7, 2022

I like this approach much better. Now we just need the Sqlite tests passing and we can get it into a pre-release for you.

@DjKillerMemeStar
Copy link
Contributor Author

@wokket wierd thing is that "it works on my machine" 🤔

I'll have a look into this after my holiday!

@erikbra
Copy link
Owner

erikbra commented Jun 11, 2022

This looks very nice, @DjKillerMemeStar ! Thank you. We must try to sort out the tests failing, though. It might be a concurrency issue. I know some of the tests might not be as fool-proof to changes as one might want. I'll try to look into the failures as well, when I get a chance.

@DjKillerMemeStar
Copy link
Contributor Author

@wokket or @erikbra is it possible to run the github actions again? I would like to see if i can fix these test but would like to see what is wrong first.

@wokket
Copy link
Collaborator

wokket commented Jul 10, 2022

I'd love to, but I'm too dumb to work out how 🤣 If you just touch a file and push it should re-trigger the CI?

@erikbra
Copy link
Owner

erikbra commented Jul 23, 2022

Hi, @DjKillerMemeStar , I've been off on vacation, so I'm just looking at this now. I tried to check out the PR, and create a branch in this repo from it, as I couldn't manage to run a build on the PR branch either. However, it seems something strange has happened to the branch? Look at the "Changes" tab on this PR, it says "0 changes", compared to erikbra/main. Do you know what has happened here?

@erikbra
Copy link
Owner

erikbra commented Aug 13, 2022

@DjKillerMemeStar - did you get a chance to look into this? The PR still says "0 changes" against main

@DjKillerMemeStar
Copy link
Contributor Author

@erikbra Yeah i've looked into it but i have no idea what happend, i think i might just do a new branch and PR and see if that fixes it.

@DjKillerMemeStar
Copy link
Contributor Author

@erikbra I've figured it out! I reverted the changes i did on my own fork, that is why this PR had no files changed. Stupid of me! But blame it on the fact that i don't use Github/fork alot :D

But this should be fine now!

@erikbra
Copy link
Owner

erikbra commented Aug 22, 2022

I've tested this locally on a real code base with existing SQL scripts, and it seems to be working great, @DjKillerMemeStar ! Great work, thanks!

I'm ready to merge this into main, adding it to a 1.4 release, which I'd like to get out soon :)

I see that we do have a couple of conflicts with main now, as other PRs have been merged in, changing main from where you started. Are you comfortable resolving those conflicts, or would you like me to assist in some way?

@DjKillerMemeStar
Copy link
Contributor Author

@DjKillerMemeStar i'm on holifay until the middle of September so it might be a while untill i get to it.

So it may be beter if you can have a look real quick, if you don't mind ofcourse.

Otherwise it will have to wait and we might get more issues.

My code is uittested so you should be able to merge pretty confident.

Sorry for the issues and time delat with this one, i'll try to do beter on the next!

@erikbra erikbra force-pushed the Add_Status_To_Version_Table branch from 4ff2d78 to 485a9da Compare August 27, 2022 22:41
@erikbra
Copy link
Owner

erikbra commented Aug 27, 2022

Thanks a lot for your efforts, @DjKillerMemeStar , and enjoy your vacation! After a few stumbles and errors I managed to et the conflicts fixed :)

@erikbra erikbra merged commit 68ebaa6 into erikbra:main Aug 27, 2022
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.

3 participants