-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Converts columns from NULL to NOT NULL DEFAULT #18871
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #18871 +/- ##
==========================================
- Coverage 46.60% 46.58% -0.03%
==========================================
Files 854 854
Lines 122891 122891
==========================================
- Hits 57271 57243 -28
- Misses 58701 58734 +33
+ Partials 6919 6914 -5
Continue to review full report at Codecov.
|
I checked the models in the migration just now. Changes are still valid. |
conflicted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking as recreating whole database is not feasable for big instances like...
gitea.com, codeberg.org, ...
Yes this can be done using alter table set default and alter table set not null for all databases except sqlite3 |
I would against about this point. Gitea is not only for codeberg, it's for everyone. In history, Gitea (gogs)'s code base is not ideal, there will be a lot of refactoring to make Gitea more "right". One instance should not be the blocker for a general purpose project. For the people who need to customize Gitea a lot, they could alter the database without downtime ahead and skip the migration manually. Update: this comment is a general thought, not for this PR. For this PR itself, I haven't fully understand the problem and have some worries and added a new comment. |
But why do you think that there could not be other large private instances? |
There could be, IMO they could either take a downtime or apply the changes manually? |
Although I think it's good to make the database columns more strict and said "I couldn't agree with that 'database migrations should be blocked by large instances'", I just mean a general thought. Sorry that I didn't say clearly in first time. For this PR I have some worries (I haven't thought about these problems carefully, just questions):
|
How would a "full test" look like?
That's "not" possible because of the
We already have lots of
Sure, we would have to add all fields to the fixtures (or enforce default values somehow). Then there would be no change to the database which is a pro or a con...? |
Just a question, not sure whether "tests/integration/migration-test" covers all cases.
I recalled some reviews mentioned that "do not write col=true/false" because it would cause broken SQL, I am not sure whether it's a real problem, so just ask the question. Update: checked with XORM code, it will change the
Just a thought, maybe there could be some "default fixtures" during testing, which contains all default values for the fields, then all loaded fixtures first get filled by default fixtures, then load the real fixture data. Update: Pros: no changes to database. Cons: may lead to inconsistent test results ..... So maybe it's not a good idea ... in the end the database should have strict structure ....... |
Is this a bug of xorm? |
Since most columns do not have an index, so most |
It's safer to update all |
Yup, that's what this PR has done, first |
Hmm ..... after some more thinking, my personal conclusion at the moment is:
So I would propose to leave this PR as it is, fix the fixtures for |
@KN4CK3R are you currently working on this? we can close this PR. |
Not working on this because it was finished back then. It's still relevant but not an easy migration for existing large instances. |
Any forward plans for this. As piece by piece migration. There are lots of migration we need |
depends on #18868 and #18869
This PR converts columns from NULL to NOT NULL DEFAULT. This should concern only the tests because the fixtures insert NULL values. The usual xorm.Inserts do not insert NULL values for int and bool.