-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add support for database schema in PostgreSQL #8819
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8819 +/- ##
=========================================
+ Coverage 42.25% 42.4% +0.14%
=========================================
Files 605 605
Lines 79268 79313 +45
=========================================
+ Hits 33497 33631 +134
+ Misses 41637 41522 -115
- Partials 4134 4160 +26
Continue to review full report at Codecov.
|
Does this also update x.Exec queries? |
I've installed Gitea from scratch in a database with no permissions on |
I'm sorry, it turns out that certain operations are problematic. Specifically, those escaping the
Other I should have tested thoroughly. 😞 I'm marking this as WIP. |
Depends on xorm/xorm#1476 |
imho setting |
@lafriks Mmmm..... I hadn't considered the scenario of many consumers using the the same login. I think Gitea should have its own login (user) and it can share the database with many other logins (users), but with its own schema. Other consumers should have their own logins and credentials. The bug reported in #5152 talks about the bad practice of having a user's tables in the Anyway, I feel that it should be xorm's job to append the schema name to all tables if so configured, even for |
Expanding on this concept, the configuration I think should be used in those cases is:
The advantage of this is having all databases backed up at the same point in time, plus better resource sharing. There are disadvantages too, but they don't really matter for this discussion. |
xorm/xorm#1476 has been merged. However, until a new version of xorm (and its companion library |
A new release of XORM was made (and our go.mod was updated), now just need for update to xormstore. |
Thank you. This PR is not in fact affected by PR ready for review. |
@guillep2k How about add a test for different schema from |
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.
Can you add the schema to the templates/admin/config.tmpl
page (if db type is postgres)?
@techknowlogick done. |
Thanks :) Dismissing my blocking review. |
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.
I still think we need some tests.
In that case I’ve moved this to 1.12 |
OK, I'll try when I have some time. But for the test to be meaningful we should run the entire integration tests through a different schema (to account for future bugs). So, the options are:
I think (1) is preferable, because it will run only once and we can consider it to be thorough. If any bug slips through (e.g. some case was not accounted for), the |
@guillep2k I'm OK to just use 1) and set |
It turns out that supporting the migration process requires additional changes in xorm. Currently the tests passes if the database is created from scratch, but on migration the To solve this I've written two more PRs for xorm: xorm/xorm#1505 and xorm/core#65. We need to wait until those are approved or another solution comes up. 😅 |
both xorm/xorm#1505 and xorm/core#65 merged. |
OK, I'll update |
@lunny Done. Build is passing. Now we have to decide if we want to use a commit ref or a version tag for xorm in A note on the tests: Integration and migration tests use the database dumps from
into
(notice the change from This is unavoidable since the tests now expect the data in the |
@guillep2k that seems to imply that the fixtures loading isn't going in to the giteatest schema? |
@zeripath They are, as always. Those are for the unit tests. The db dumps I've changed are used as starting points for the migration and integration tests (I don't know what role the fixtures play in that case, but I changed nothing about them). My only change was using an alternte schema in the case of PGSQL. |
They're also used for the integration tests. The migration data should really be dropped after its tests |
I didn't change any behaviour there. I just expanded the gzip files, edited the SQL, changed The yaml fixtures are not affected by this PR in any way, since those are loaded through the database connection so they inherit the proper enviroment. |
Cool. I just misunderstood what you were saying. |
Fixes #5152
Currently Gitea does not support using a database schema different from the default "public". With this PR, a schema different from the default can be specified in
app.ini
and during install.