-
-
Notifications
You must be signed in to change notification settings - Fork 7.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
chore: use db model instead of content type #19563
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cff9828
chore: use db model instead of content type
remidej 3c1205c
chore: remove content type ref in comment
remidej 67ba6d7
fix: remove contentTypes from CM index
remidej 7711203
fix: yet another model import
remidej 91b8cda
fix: mark feedback
remidej dfb7352
Merge remote-tracking branch 'origin/v5/history' into history/model
remidej File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
packages/core/content-manager/server/src/history/content-types/history-version.ts
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
packages/core/content-manager/server/src/history/content-types/index.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/core/content-manager/server/src/history/models/history-version.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { Model } from '@strapi/database'; | ||
import { HISTORY_VERSION_UID } from '../constants'; | ||
|
||
const historyVersion: Model = { | ||
uid: HISTORY_VERSION_UID, | ||
tableName: 'strapi_history_versions', | ||
singularName: 'history-version', | ||
attributes: { | ||
id: { | ||
type: 'increments', | ||
}, | ||
contentType: { | ||
type: 'string', | ||
column: { notNullable: true }, | ||
}, | ||
relatedDocumentId: { | ||
type: 'string', | ||
column: { notNullable: true }, | ||
}, | ||
locale: { | ||
type: 'string', | ||
}, | ||
status: { | ||
type: 'enumeration', | ||
enum: ['draft', 'published', 'modified'], | ||
}, | ||
data: { | ||
type: 'json', | ||
}, | ||
schema: { | ||
type: 'json', | ||
}, | ||
createdAt: { | ||
type: 'datetime', | ||
default: () => new Date(), | ||
}, | ||
// FIXME: joinTable should be optional | ||
// @ts-expect-error database model is not yet updated to support useJoinTable | ||
createdBy: { | ||
type: 'relation', | ||
relation: 'oneToOne', | ||
target: 'admin::user', | ||
useJoinTable: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export { historyVersion }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is it necessary to use a join table for the created by field?
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.
Do you think it would be? Here it's false, and for normal content types it's false as well
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.
didn't select the right section 😓 I think the attribute is correctly set up and will not use a join table, but there is a message about jointable being optional and didn't get why 🤔
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.
Ah I see. The comment is because TS wanted us to provide a joinTable property (not sure about the name exactly). But it shouldn't be required when useJoinTable is false. The type isn't smart enough for that yet, that's why we expect a TS error here