Skip to content

Add option to import old database - #1847

Closed
6543 wants to merge 67 commits into
woodpecker-ci:mainfrom
6543-forks:add_option_to_import_old_database
Closed

6543 wants to merge 67 commits into
woodpecker-ci:mainfrom
6543-forks:add_option_to_import_old_database

Conversation

@6543

@6543 6543 commented Jun 10, 2023 •

Copy link
Copy Markdown
Member

close #924

@6543 6543 added server feature add new functionality labels Jun 10, 2023
@6543 6543 added the wip label Jun 10, 2023
@6543 6543 removed the wip label Jun 10, 2023
@6543 6543 added this to the 1.0.0 milestone Jun 10, 2023
@6543
6543 requested a review from qwerty287 June 10, 2023 20:03
@codecov-commenter

codecov-commenter commented Jun 10, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 26.03550% with 125 lines in your changes missing coverage. Please review.

Project coverage is 26.50%. Comparing base (b0f52b9) to head (08d4245).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
server/store/datastore/migration/copy_generated.go 3.57% 36 Missing and 18 partials ⚠️
server/store/datastore/migration/copy.go 49.33% 30 Missing and 8 partials ⚠️
cmd/server/setup.go 0.00% 23 Missing ⚠️
server/store/datastore/engine.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1847      +/-   ##
==========================================
- Coverage   26.52%   26.50%   -0.02%     
==========================================
  Files         377      380       +3     
  Lines       27448    27668     +220     
==========================================
+ Hits         7281     7334      +53     
- Misses      19503    19642     +139     
- Partials      664      692      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@6543
6543 requested a review from a team June 11, 2023 01:08
@woodpecker-bot

woodpecker-bot commented Jun 11, 2023 •

Copy link
Copy Markdown
Contributor

Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-1847.surge.sh

@lafriks

lafriks commented Jun 11, 2023

Copy link
Copy Markdown
Contributor

Should migrations also be run for old database?

@6543

6543 commented Jun 11, 2023

Copy link
Copy Markdown
Member Author

@lafriks yes in import, migration only will run on old database. If we want to change that, we would have to have a copy of the models for each schema we had in the past

@6543

6543 commented Jun 11, 2023

Copy link
Copy Markdown
Member Author

Also this help us to drop quirks that might existing in old databases as we init the schema on the new db as if it was a new install and then just copy data that fits in the current models

@qwerty287 qwerty287 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah OK that's valid. I still prefer a generic tool but if you really think that's a good addition...

Can you move the code as far as possible to its own module? Not directly in migrations, rather something like migrations/dbms

}

// copy data
// IMPORTANT: if you add something here, also add it to migration.go allBeans slice

@qwerty287 qwerty287 Aug 17, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please resolve this todo.

Actually I don't really get why this needs to be done with generics. In the end, it seems that you only use this type to:

  1. Use new(T) which can be directly replaced by the value which is also in allBeans
  2. Create the list to run xorm Find.

AFAIK xorm supports setting a table explicitly so it might be possible to use an any type for the second case but setting the table explicitly using the value from allBeans?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sadly this wont work, i tried hard to ose the any type ... or reflections.

but i could not create a list of items based on any ... if i dont batch and itterate over each item by one it might work ... but that is sure inefficient!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK, I get what you mean, tried it as well. Can you ask xorm about this? I'd like to have this fixed first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

xorm per se can not do anything ... it would have to add an Database-Migration-Feature.
that will work

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't want them to implement something like this, just that you can use Find with []any would help a lot

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the problem is that then you have to validate each item in the list ... that slows down the whole orm!

@anbraten

Copy link
Copy Markdown
Member

Yeah OK that's valid. I still prefer a generic tool but if you really think that's a good addition...

I would actually prefer to put it in a separate repo as a separate cli tool as well.

@6543 6543 added the build_pr_images If set, the CI will build images for this PR and push to Dockerhub label Sep 5, 2024
@6543

6543 commented Oct 1, 2024

Copy link
Copy Markdown
Member Author

now it's code generated so there should be no problem with maintenance burden

@qwerty287

Copy link
Copy Markdown
Contributor

I'd still prefer this in a separate tool, it shouldn't be a problem to import WP's models. This is not a task that's done often I think

@6543

6543 commented Nov 6, 2024

Copy link
Copy Markdown
Member Author

well the "separate tool" is currently this pulls preview images ... witch I use for my migrations.

If one does pick it up and make a nice tool then this one should do so.

@qwerty287

Copy link
Copy Markdown
Contributor

So you don't plan to get this merged into main? In this case, I'd rather use a separate docker repo and close this pr

@6543

6543 commented Nov 6, 2024

Copy link
Copy Markdown
Member Author

well I personally do wana get it merged ... but there is no majority for it

@qwerty287

Copy link
Copy Markdown
Contributor

Yes, so we probably won't merge it. Then the PR should be closed and this tool can live in a separate branch, but not in a PR.

@6543

6543 commented Nov 9, 2024

Copy link
Copy Markdown
Member Author

well that's as majour as the build-in function could go.

as everybody want to just have an external tool ... well I did the migrations I had to.

@6543 6543 closed this Nov 9, 2024
@6543
6543 deleted the add_option_to_import_old_database branch November 9, 2024 19:23
@qwerty287 qwerty287 mentioned this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build_pr_images If set, the CI will build images for this PR and push to Dockerhub feature add new functionality server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to migrate database

7 participants