-
Notifications
You must be signed in to change notification settings - Fork 1
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
Migrate database to GORM and new schema #8
base: master
Are you sure you want to change the base?
Conversation
d79b75b
to
a4e62e8
Compare
a4e62e8
to
2cf6e37
Compare
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.
Some questions and comments. Haven't had the time to review the tests yet.
share/model.go
Outdated
"gorm.io/gorm" | ||
) | ||
|
||
// +---------------------------------+-----------------+------+-----+---------+----------------+ |
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.
This might be useful in the migration script, but I would clean it from here.
share/model.go
Outdated
gorm.Model | ||
UIDOwner string | ||
UIDInitiator string | ||
ItemType string // file | folder |
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.
Enum? Btw, ResourceTypeToItem
can return other strings.
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.
Real Enum's don't exist in Go, but I can do something like this:
type ItemType string
const (
ItemTypeFile ItemType = "file"
ItemTypeFolder ItemType = "folder"
ItemTypeReference ItemType = "reference"
ItemTypeSymlink ItemType = "symlink"
)
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.
outside of this package you can then do share.ItemTypeFile
for example (you can also do illegal values, but then you would have to do ItemType("illegal-value")
), so I think this should at least make it clear and kind of enforces it
share/model.go
Outdated
|
||
type ProtoShare struct { | ||
// Including gorm.Model will embed a number of gorm-default fields | ||
// such as creation_time, id etc |
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 put the full list of defaults?
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'll maybe just remove the "// such as creation_time, id etc" then, you can see the fields by hovering over gorm.Model :)
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.
Remove it then!
share/model.go
Outdated
InitialPath string | ||
Inode string | ||
FileSource int64 | ||
FileTarget string |
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 no longer remember what was this FileSource and FileTarget. Maybe it would be worth to have some description for some of these fields. For future reference.
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.
FileSource
seems to be the same as ItemSource, i.e. the inode (this is true for all but 8 of the entries in the prod db). So this can maybe also be dropped.
FileTarget
seems to be the last part of the path of the file, e.g. /MyFile.txt
. Since we have the InitialPath
now I think we could also drop this
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 think we decided to drop those, but I don't see a comment like that in the rfc file you did... Confirm in the code where these are used and drop them if ok.
6b8c45a
to
7843bfb
Compare
f2d54aa
to
48683cf
Compare
48683cf
to
ad9587a
Compare
58d68e6
to
af4e08d
Compare
Following ADR-Reva-003, this PR refactors the sharing SQL logic to now use GORM, an ORM for Go. This change also comes with newly written unit tests for all the database logic.