Skip to content

Commit

Permalink
fix: inconsistent table column for creator-id of media
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf committed Oct 20, 2024
1 parent 6cc7384 commit 4116546
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
16 changes: 10 additions & 6 deletions apps/nextjs/src/app/[locale]/manage/medias/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ const Row = ({ media }: RowProps) => {
<TableTd>{media.name}</TableTd>
<TableTd>{humanFileSize(media.size)}</TableTd>
<TableTd>
<Group gap="sm">
<UserAvatar user={media.creator} size="sm" />
<Anchor component={Link} href={`/manage/users/${media.creator.id}/general`} size="sm">
{media.creator.name}
</Anchor>
</Group>
{media.creator ? (
<Group gap="sm">
<UserAvatar user={media.creator} size="sm" />
<Anchor component={Link} href={`/manage/users/${media.creator.id}/general`} size="sm">
{media.creator.name}
</Anchor>
</Group>
) : (
"-"
)}
</TableTd>
<TableTd w={64}>
<Group wrap="nowrap" gap="xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ CREATE TABLE `media` (
`content_type` text NOT NULL,
`size` integer NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
`creator_id` text NOT NULL,
`creator_id` text,
FOREIGN KEY (`creator_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE set null
);
4 changes: 2 additions & 2 deletions packages/db/migrations/sqlite/meta/0013_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "47e54544-6cf1-4651-951b-8cddc7e18297",
"id": "186369ac-b155-4a88-902d-c03e3fa31e6a",
"prevId": "20b3ebeb-a111-4576-b530-a2634d154132",
"tables": {
"account": {
Expand Down Expand Up @@ -1125,7 +1125,7 @@
"name": "creator_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"notNull": false,
"autoincrement": false
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/db/migrations/sqlite/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
{
"idx": 13,
"version": "6",
"when": 1729353773935,
"tag": "0013_demonic_captain_america",
"when": 1729415919596,
"tag": "0013_bent_alex_wilder",
"breakpoints": true
}
]
Expand Down
4 changes: 1 addition & 3 deletions packages/db/schema/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ export const medias = sqliteTable("media", {
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`(unixepoch())`),
creatorId: text("creator_id")
.notNull()
.references(() => users.id, { onDelete: "set null" }),
creatorId: text("creator_id").references(() => users.id, { onDelete: "set null" }),
});

export const integrations = sqliteTable(
Expand Down

0 comments on commit 4116546

Please sign in to comment.